简体   繁体   English

Java链接列表数组

[英]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). 创建大小为Integer_MAX(自定义链接列表)的链接列表数组。
  2. Insert values (int's) to the Linked Lists whose number is key number. 将值(int)插入到编号为键编号的链接列表中。

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. 现在,由于我们将存储近5亿个关键值对,因此将浪费1600万个链接列表。

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 . 目前的代码( Louis Wasserman )可以在这里找到

You can not create an array of generic type because array is reified type. 您无法创建泛型类型的数组,因为数组是reified类型。 Generics are implemented by erasure. 泛型通过擦除实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM