Arpssss
Arpssss

Reputation: 3858

Java Array of Linked Lists

I am trying to code a custom hashtable which can allows multiple values.

We are doing it in following way:

  1. Create an array of Linked Lists of the size Integer_MAX (custom linked list).
  2. Insert values (int's) to the Linked Lists whose number is key number.

Means structure like:

value1 -> value6
NULL
Null
value3 -> value7
Null
...
...(until Int-Max)

Now, as we will store nearly 500 millions of key value pairs, at-lest 1600 millions link lists are going to be wasted.

Now, as per suggestion fro my working place, I am trying to build hashtable with structure like:

1 -> value1 -> value6
0
0
1 -> value3 -> value7  // here 0/1 bit defines linked lists exits or not
0
...
...(until Int-Max)

Can anybody help me is this possible to build such kind of structure ?

Edit:

  1. Why we are trying to do this can be found here.
  2. Current code (by Louis Wasserman) can be found here.

Upvotes: 4

Views: 387

Answers (1)

gkuzmin
gkuzmin

Reputation: 2484

You can not create an array of generic type because array is reified type. Generics are implemented by erasure.

Upvotes: 1

Related Questions