项目:trove-3.0.3
文件:THashTest.java
public void testTPrimitivePrimitveHashMapConstructors() {
int cap = 20;
TIntLongMap cap_and_factor = new TIntLongHashMap( cap,0.75f );
TPrimitiveHash cap_and_factor_hash = (TPrimitiveHash) cap_and_factor;
assertTrue( "capacity not sufficient: " + cap + "," + cap_and_factor_hash.capacity(),cap <= cap_and_factor_hash.capacity() );
assertEquals( 0.75f,cap_and_factor_hash._loadFactor );
TIntLongMap fully_specified =
new TIntLongHashMap( cap,0.5f,Integer.MIN_VALUE,Long.MIN_VALUE );
TPrimitiveHash fully_specified_hash = (TPrimitiveHash) fully_specified;
assertTrue( "capacity not sufficient: " + cap + "," + fully_specified_hash.capacity(),cap <= fully_specified_hash.capacity() );
assertEquals( 0.5f,fully_specified_hash._loadFactor );
assertEquals( Integer.MIN_VALUE,fully_specified.getNoEntryKey() );
assertEquals( Long.MIN_VALUE,fully_specified.getNoEntryValue() );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testGet() {
int element_count = 20;
int[] keys = new int[element_count];
Long[] vals = new Long[element_count];
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Long.valueOf( i + 1 );
raw_map.put( keys[i],vals[i] );
}
Map<Integer,Long> map = TDecorators.wrap( raw_map );
assertEquals( vals[10],map.get( Integer.valueOf( keys[10] ) ) );
assertNull( map.get( Integer.valueOf( 1138 ) ) );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
/** Be sure that size is large enough to force a resize or two. */
public void testRehash() {
int size = 1000;
int[] keys = new int[size];
long[] vals = new long[size];
for ( int i = 0; i < size; i++ ) {
keys[i] = i + 1;
vals[i] = keys[i] * 2;
}
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
raw_map.put( keys[i],Long> map = TDecorators.wrap( raw_map );
assertEquals( keys.length,map.size() );
for ( int i = 0; i < keys.length; i++ ) {
Integer key = keys[i];
Long val = vals[i];
assertEquals( "got incorrect value for index " + i + ",map: " + map,val,map.get( key ) );
}
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testClear() {
int[] keys = {1138,42,86,99,101};
long[] vals = {1138,101};
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
raw_map.put( keys[i],vals[i] * 2 );
}
Map<Integer,map.size() );
map.clear();
assertEquals( 0,map.size() );
assertTrue( map.isEmpty() );
TIntLongMap raw_empty = new TIntLongHashMap();
Map<Integer,Long> empty = TDecorators.wrap( raw_empty );
assertEquals( empty,map );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testRemove() {
int[] keys = {1138,101,727,117};
Long[] vals = new Long[keys.length];
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = Long.valueOf( keys[i] * 2 );
raw_map.put( keys[i],Long> map = TDecorators.wrap( raw_map );
assertEquals( keys.length,map.size() );
for ( int i = 0; i < keys.length; i++ ) {
assertEquals( vals[i],map.get( keys[i] ) );
}
assertEquals( vals[0],map.remove( keys[0] ) );
assertEquals( vals[3],map.remove( keys[3] ) );
assertNull( map.remove( keys[0] ) );
assertEquals( vals[5],map.remove( keys[5] ) );
assertNull( map.remove( 11010110 ) );
assertNull( map.get( 1138 ) );
//noinspection SuspiciousMethodCalls
assertNull( map.get( Integer.valueOf( 1138 ) ) );
assertNull( map.get( null ) );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetHashCode() {
int[] keys = {1138,117};
Integer[] integer_keys = new Integer[keys.length];
long[] vals = new long[keys.length];
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
integer_keys[i] = Integer.valueOf( keys[i] );
vals[i] = keys[i] * 2;
raw_map.put( keys[i],Long> map = TDecorators.wrap( raw_map );
Set<Integer> set = map.keySet();
assertEquals( map.size(),set.size() );
assertFalse( set.isEmpty() );
Set<Integer> other = new HashSet<Integer>();
other.addAll( Arrays.asList( integer_keys ) );
assertTrue( "hashcodes incorrectly not equal: " + set + "," + other,set.hashCode() == other.hashCode() );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testSerialize() throws Exception {
int[] keys = {1138,117};
long[] vals = new long[keys.length];
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
raw_map.put( keys[i],Long> map = TDecorators.wrap( raw_map );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( map );
ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() );
ObjectInputStream ois = new ObjectInputStream( bias );
//noinspection unchecked
Map<Integer,Long> deserialized = (Map<Integer,Long>) ois.readObject();
assertEquals( map,deserialized );
}
项目:trove-over-koloboke-compile
文件:THashTest.java
public void testTPrimitivePrimitveHashMapConstructors() {
int cap = 20;
TIntLongMap cap_and_factor = new TIntLongHashMap( cap,fully_specified.getNoEntryValue() );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
/** Be sure that size is large enough to force a resize or two. */
public void testRehash() {
int size = 1000;
int[] keys = new int[size];
long[] vals = new long[size];
for ( int i = 0; i < size; i++ ) {
keys[i] = i + 1;
vals[i] = keys[i] * 2;
}
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
raw_map.put( keys[i],map.get( key ) );
}
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testClear() {
int[] keys = {1138,map );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetHashCode() {
int[] keys = {1138,117};
Integer[] integer_keys = new Integer[keys.length];
long[] vals = new long[keys.length];
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
integer_keys[i] = Integer.valueOf( keys[i] );
vals[i] = keys[i] * 2;
raw_map.put( keys[i],vals[i] );
}
Map<Integer,Long> map = TDecorators.wrap( raw_map );
Set<Integer> set = map.keySet();
assertEquals( map.size(),set.size() );
assertFalse( set.isEmpty() );
Set<Integer> other = new HashSet<Integer>();
other.addAll( Arrays.asList( integer_keys ) );
assertTrue( "hashcodes incorrectly not equal: " + set + ",set.hashCode() == other.hashCode() );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testSerialize() throws Exception {
int[] keys = {1138,deserialized );
}
项目:gnu.trove
文件:THashTest.java
public void testTPrimitivePrimitveHashMapConstructors() {
int cap = 20;
TIntLongMap cap_and_factor = new TIntLongHashMap( cap,fully_specified.getNoEntryValue() );
}
项目:gnu.trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
/** Be sure that size is large enough to force a resize or two. */
public void testRehash() {
int size = 1000;
int[] keys = new int[size];
long[] vals = new long[size];
for ( int i = 0; i < size; i++ ) {
keys[i] = i + 1;
vals[i] = keys[i] * 2;
}
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
raw_map.put( keys[i],map.get( key ) );
}
}
项目:gnu.trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testClear() {
int[] keys = {1138,map );
}
项目:gnu.trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetHashCode() {
int[] keys = {1138,set.hashCode() == other.hashCode() );
}
项目:gnu.trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testSerialize() throws Exception {
int[] keys = {1138,deserialized );
}
项目:trove
文件:THashTest.java
public void testTPrimitivePrimitveHashMapConstructors() {
int cap = 20;
TIntLongMap cap_and_factor = new TIntLongHashMap( cap,fully_specified.getNoEntryValue() );
}
项目:trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
/** Be sure that size is large enough to force a resize or two. */
public void testRehash() {
int size = 1000;
int[] keys = new int[size];
long[] vals = new long[size];
for ( int i = 0; i < size; i++ ) {
keys[i] = i + 1;
vals[i] = keys[i] * 2;
}
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
raw_map.put( keys[i],map.get( key ) );
}
}
项目:trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testClear() {
int[] keys = {1138,map );
}
项目:trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetHashCode() {
int[] keys = {1138,set.hashCode() == other.hashCode() );
}
项目:trove
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testSerialize() throws Exception {
int[] keys = {1138,deserialized );
}
项目:morpheus-core
文件:SparseArrayOfZonedDateTimes.java
/**
* Constructor
* @param length the length for this array
*/
SparseArrayOfZonedDateTimes(int length,ZonedDateTime defaultValue) {
super(ZonedDateTime.class,ArrayStyle.SPARSE,false);
this.length = length;
this.defaultValue = defaultValue;
this.defaultValueAsLong = defaultValue != null ? defaultValue.toInstant().toEpochMilli() : nullValue;
this.defaultZoneId = defaultValue != null ? zoneIdMap1.get(defaultValue.getZone()) : NULL_ZONE;
this.values = new TIntLongHashMap((int)Math.max(length * 0.5,10d),0.8f,-1,defaultValueAsLong);
this.zoneIds = new TIntShortHashMap((int)Math.max(length * 0.5,defaultZoneId);
}
项目:morpheus-core
文件:SparseArrayWithLongCoding.java
/**
* Constructor
* @param length the length for this array
* @param defaultValue the default value for array
* @param coding the coding for this array
*/
SparseArrayWithLongCoding(int length,T defaultValue,LongCoding<T> coding) {
super(coding.getType(),false);
this.length = length;
this.coding = coding;
this.defaultValue = defaultValue;
this.defaultCode = coding.getCode(defaultValue);
this.codes = new TIntLongHashMap((int)Math.max(length * 0.5,defaultCode);
}
项目:morpheus-core
文件:SparseArrayOfLongs.java
/**
* Constructor
* @param length the length for this array
* @param defaultValue the default value for array
*/
SparseArrayOfLongs(int length,Long defaultValue) {
super(Long.class,false);
this.length = length;
this.defaultValue = defaultValue != null ? defaultValue : 0L;
this.values = new TIntLongHashMap((int)Math.max(length * 0.5,this.defaultValue);
}
项目:trove-3.0.3
文件:THashTest.java
public void testTPrimitivePrimitveHashMapSerialize() throws Exception {
int[] keys = {1138,117};
long[] vals = new long[keys.length];
TIntLongMap original_map =
new TIntLongHashMap( 200,0.75f,Long.MIN_VALUE );
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
original_map.put( keys[i],vals[i] );
}
THash original_hash = ( THash ) original_map;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( original_map );
ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() );
ObjectInputStream ois = new ObjectInputStream( bias );
TIntLongMap deserialized_map = ( TIntLongMap ) ois.readObject();
THash deserialized_hash = ( THash ) deserialized_map;
assertEquals( original_map,deserialized_map );
assertEquals( original_map.getNoEntryKey(),deserialized_map.getNoEntryKey() );
assertEquals( original_map.getNoEntryValue(),deserialized_map.getNoEntryValue() );
assertEquals( original_hash._loadFactor,deserialized_hash._loadFactor );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetContainsAll() {
int[] keys = {1138,set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int key : keys ) {
java_set.add( Integer.valueOf( key ) );
}
assertTrue( set.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( set.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetEquals() {
int[] keys = {1138,set.size() );
assertFalse( set.isEmpty() );
Set<Integer> other = new HashSet<Integer>();
other.addAll( Arrays.asList( integer_keys ) );
assertTrue( "sets incorrectly not equal: " + set + ",set.equals( other ) );
Integer[] mismatched = {72,49,53,1024,999};
Set<Integer> unequal = new HashSet<Integer>();
unequal.addAll( Arrays.asList( mismatched ) );
assertFalse( "sets incorrectly equal: " + set + "," + unequal,set.equals( unequal ) );
// Change length,different code branch
unequal.add( 1 );
assertFalse( "sets incorrectly equal: " + set + ",set.equals( unequal ) );
assertFalse( "set incorrectly equals a random object",set.equals( new Object() ) );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testValueCollectionContainsAll() {
int[] keys = {1138,Long> map = TDecorators.wrap( raw_map );
Collection<Long> values = map.values();
assertEquals( map.size(),values.size() );
assertFalse( values.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( long val : vals ) {
java_set.add( Long.valueOf( val ) );
}
assertTrue( values.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( values.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testHashCode() {
int[] keys = {1138,Long> map = TDecorators.wrap( raw_map );
TIntLongMap raw_other = new TIntLongHashMap();
Map<Integer,Long> other = TDecorators.wrap( raw_other );
other.putAll( map );
assertTrue( "hashcodes incorrectly not equal: " + map + ",map.hashCode() == other.hashCode() );
TIntLongMap raw_unequal = new TIntLongHashMap();
for ( int key : keys ) {
raw_unequal.put( key,key );
}
Map<Integer,Long> unequal = TDecorators.wrap( raw_unequal );
assertFalse( "hashcodes unlikely equal: " + map + ",map.hashCode() == unequal.hashCode() );
int[] raw_mismatched = {72,999};
TIntLongMap raw_mismatched_map = new TIntLongHashMap();
for ( int aRaw_mismatched : raw_mismatched ) {
raw_mismatched_map.put( aRaw_mismatched,Long.valueOf( aRaw_mismatched * 37 ) );
}
Map<Integer,Long> mismatched = TDecorators.wrap( raw_mismatched_map );
assertFalse( "hashcodes unlikely equal: " + map + "," + mismatched,map.hashCode() == mismatched.hashCode() );
}
项目:trove-3.0.3
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testToString() {
TIntLongMap raw_map = new TIntLongHashMap();
Map<Integer,Long> map = TDecorators.wrap( raw_map );
map.put( 11,Long.valueOf( 1 ) );
map.put( 22,Long.valueOf( 2 ) );
String to_string = map.toString();
assertTrue( to_string,to_string.equals( "{11=1,22=2}" ) ||
to_string.equals( "{22=2,11=1}" ) );
}
项目:monsoon
文件:MetricTable.java
public MetricTable(int timestampsSize) {
this.timestampsSize = timestampsSize;
this.t_bool = new TIntByteHashMap(timestampsSize,1,(byte) -1);
this.t_16bit = new TIntShortHashMap(timestampsSize,(short) -1);
this.t_32bit = new TIntIntHashMap(timestampsSize,-1);
this.t_64bit = new TIntLongHashMap(timestampsSize,-1);
this.t_dbl = new TIntDoubleHashMap(timestampsSize,-1);
this.t_str = new TIntIntHashMap(timestampsSize,-1);
this.t_hist = new TIntObjectHashMap<>(timestampsSize,-1);
this.t_empty = new TIntHashSet(timestampsSize,-1);
this.t_other = new TIntObjectHashMap<>(timestampsSize,-1);
}
项目:trove-over-koloboke-compile
文件:THashTest.java
public void testTPrimitivePrimitveHashMapSerialize() throws Exception {
int[] keys = {1138,deserialized_hash._loadFactor );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testGet() {
int element_count = 20;
int[] keys = new int[element_count];
Long[] vals = new Long[element_count];
TIntLongMap raw_map = new TIntLongHashMap();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Long.valueOf( i + 1 );
raw_map.put( keys[i],map.get( Integer.valueOf( keys[10] ) ) );
assertNull( map.get( Integer.valueOf( 1138 ) ) );
Integer key = Integer.valueOf( 1138 );
map.put( key,null );
assertTrue( map.containsKey( key ) );
assertNull( map.get( key ) );
Long long_key = Long.valueOf( 1138 );
//noinspection SuspiciousMethodCalls
assertNull( map.get( long_key ) );
Long null_value = Long.valueOf( 747 );
map.put( null,null_value );
assertEquals( null_value,map.get( null ) );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testRemove() {
int[] keys = {1138,map.remove( keys[5] ) );
assertNull( map.remove( 11010110 ) );
assertNull( map.get( 1138 ) );
//noinspection SuspiciousMethodCalls
assertNull( map.get( Integer.valueOf( 1138 ) ) );
assertNull( map.get( null ) );
Long null_value = Long.valueOf( 2112 );
map.put( null,null_value );
assertEquals( null_value.longValue(),raw_map.get( raw_map.getNoEntryKey() ) );
assertTrue( map.containsKey( null ) );
Long value = map.get( null );
assertEquals( "value: " + value,null_value,value );
assertEquals( null_value,map.remove( null ) );
assertFalse( map.containsKey( null ) );
//noinspection SuspiciousMethodCalls
assertNull( map.remove( Long.valueOf( 1138 ) ) );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetContainsAll() {
int[] keys = {1138,set.size() );
assertFalse( set.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( int key : keys ) {
java_set.add( Integer.valueOf( key ) );
}
assertTrue( set.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( set.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( set.containsAll( java_set ) );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testKeySetEquals() {
int[] keys = {1138,set.equals( new Object() ) );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testValueCollectionContainsAll() {
int[] keys = {1138,values.size() );
assertFalse( values.isEmpty() );
// test with a java.util.Map
Set<Number> java_set = new HashSet<Number>();
for ( long val : vals ) {
java_set.add( Long.valueOf( val ) );
}
assertTrue( values.containsAll( java_set ) );
java_set.add( Integer.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
java_set.remove( Integer.valueOf( 12 ) );
assertTrue( values.containsAll( java_set ) );
java_set.add( Long.valueOf( 12 ) );
assertFalse( values.containsAll( java_set ) );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testHashCode() {
int[] keys = {1138,map.hashCode() == mismatched.hashCode() );
}
项目:trove-over-koloboke-compile
文件:TPrimitivePrimitiveMapDecoratorTest.java
public void testToString() {
TIntLongMap raw_map = new TIntLongHashMap();
Map<Integer,11=1}" ) );
}