@Test public void testEmpty() { HashTableGenerator<String, Constant> gen = new HashTableGenerator<String, Constant>(new StringHash(), 2); StructureConstant result = gen.generate(); assertEquals("{i32 0, i32 4, i32 0, i32 0, i32 0, i32 0, i32 0}", result.toString()); }
public StructureConstant generate() { StructureConstantBuilder builder = new StructureConstantBuilder(); int start = 0; builder.add(new IntegerConstant(count)); builder.add(new IntegerConstant(table.length, INDEX_TYPE)); builder.add(new IntegerConstant(start, INDEX_TYPE)); for (int i = 1; i <= table.length; i++) { if (table[i - 1] == null) { builder.add(new IntegerConstant(start, INDEX_TYPE)); } else { start += table[i - 1].size(); builder.add(new IntegerConstant(start, INDEX_TYPE)); } } for (int i = 0; i < table.length; i++) { if (table[i] != null) { for (Entry<K, V> entry : table[i]) { builder.add(entry.v); } } } return builder.build(); }
HashTableGenerator { public StructureConstant generate() { StructureConstantBuilder builder = new StructureConstantBuilder(); int start = 0; builder.add(new IntegerConstant(count)); builder.add(new IntegerConstant(table.length, INDEX_TYPE)); builder.add(new IntegerConstant(start, INDEX_TYPE)); for (int i = 1; i <= table.length; i++) { if (table[i - 1] == null) { builder.add(new IntegerConstant(start, INDEX_TYPE)); } else { start += table[i - 1].size(); builder.add(new IntegerConstant(start, INDEX_TYPE)); } } for (int i = 0; i < table.length; i++) { if (table[i] != null) { for (Entry<K, V> entry : table[i]) { builder.add(entry.v); } } } return builder.build(); } }
HashTableGenerator { public StructureConstant generate() { StructureConstantBuilder builder = new StructureConstantBuilder(); int start = 0; builder.add(new IntegerConstant(count)); builder.add(new IntegerConstant(table.length, INDEX_TYPE)); builder.add(new IntegerConstant(start, INDEX_TYPE)); for (int i = 1; i <= table.length; i++) { if (table[i - 1] == null) { builder.add(new IntegerConstant(start, INDEX_TYPE)); } else { start += table[i - 1].size(); builder.add(new IntegerConstant(start, INDEX_TYPE)); } } for (int i = 0; i < table.length; i++) { if (table[i] != null) { for (Entry<K, V> entry : table[i]) { builder.add(entry.v); } } } return builder.build(); } HashTableGenerator(HashFunction<K> function);  HashTableGenerator(HashFunction<K> function, int tableSize);  HashTableGenerator(HashFunction<K> function, int tableSize, double loadFactor); }
HashTableGenerator { public StructureConstant generate() { StructureConstantBuilder builder = new StructureConstantBuilder(); int start = 0; builder.add(new IntegerConstant(count)); builder.add(new IntegerConstant(table.length, INDEX_TYPE)); builder.add(new IntegerConstant(start, INDEX_TYPE)); for (int i = 1; i <= table.length; i++) { if (table[i - 1] == null) { builder.add(new IntegerConstant(start, INDEX_TYPE)); } else { start += table[i - 1].size(); builder.add(new IntegerConstant(start, INDEX_TYPE)); } } for (int i = 0; i < table.length; i++) { if (table[i] != null) { for (Entry<K, V> entry : table[i]) { builder.add(entry.v); } } } return builder.build(); } HashTableGenerator(HashFunction<K> function);  HashTableGenerator(HashFunction<K> function, int tableSize);  HashTableGenerator(HashFunction<K> function, int tableSize, double loadFactor); void put(K k, V v); StructureConstant generate(); }
HashTableGenerator { public StructureConstant generate() { StructureConstantBuilder builder = new StructureConstantBuilder(); int start = 0; builder.add(new IntegerConstant(count)); builder.add(new IntegerConstant(table.length, INDEX_TYPE)); builder.add(new IntegerConstant(start, INDEX_TYPE)); for (int i = 1; i <= table.length; i++) { if (table[i - 1] == null) { builder.add(new IntegerConstant(start, INDEX_TYPE)); } else { start += table[i - 1].size(); builder.add(new IntegerConstant(start, INDEX_TYPE)); } } for (int i = 0; i < table.length; i++) { if (table[i] != null) { for (Entry<K, V> entry : table[i]) { builder.add(entry.v); } } } return builder.build(); } HashTableGenerator(HashFunction<K> function);  HashTableGenerator(HashFunction<K> function, int tableSize);  HashTableGenerator(HashFunction<K> function, int tableSize, double loadFactor); void put(K k, V v); StructureConstant generate();  }