当前位置: 首页>>代码示例>>Java>>正文


Java Hash类代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.Hash的典型用法代码示例。如果您正苦于以下问题:Java Hash类的具体用法?Java Hash怎么用?Java Hash使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Hash类属于it.unimi.dsi.fastutil包,在下文中一共展示了Hash类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRemove0

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testRemove0() {
	IntLinkedOpenHashSet s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = -1; i <= 1; i++ ) assertTrue( s.add( i ) );
	assertTrue( s.remove( 0 ) );
	IntListIterator iterator = s.iterator();
	assertEquals( -1, iterator.nextInt() );
	assertEquals( 1, iterator.nextInt() );
	assertFalse( iterator.hasNext() );
	
	s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = -1; i <= 1; i++ ) assertTrue( s.add( i ) );
	iterator = s.iterator();
	assertEquals( -1, iterator.nextInt() );
	assertEquals( 0, iterator.nextInt() );
	iterator.remove();
	assertEquals( 1, iterator.nextInt() );
	assertFalse( iterator.hasNext() );

	assertFalse( s.contains( 0 ) );
	
	iterator = s.iterator();
	assertEquals( -1, iterator.nextInt() );
	assertEquals( 1, iterator.nextInt() );
	assertFalse( iterator.hasNext() );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:27,代码来源:IntLinkedOpenHashSetTest.java

示例2: testFirtLast0

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testFirtLast0() {
	IntLinkedOpenHashSet s;
	
	s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 0; i < 100; i++ ) assertTrue( s.add( i ) );
	for( int i = 0; i < 100; i++ ) assertEquals( i, s.removeFirstInt() );
	assertTrue( s.isEmpty() );
	
	s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 0; i < 100; i++ ) assertTrue( s.add( i ) );
	for( int i = 100; i-- != 0; ) assertEquals( i, s.removeLastInt() );
	assertTrue( s.isEmpty() );

	s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 100; i-- != 0; ) assertTrue( s.add( i ) );
	for( int i = 0; i < 100; i++ ) assertEquals( i, s.removeLastInt() );
	assertTrue( s.isEmpty() );

	s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 100; i-- != 0; ) assertTrue( s.add( i ) );
	for( int i = 100; i-- != 0; ) assertEquals( i, s.removeFirstInt() );
	assertTrue( s.isEmpty() );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:25,代码来源:IntLinkedOpenHashSetTest.java

示例3: testRemove0

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testRemove0() {
	IntOpenHashSet s = new IntOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = -1; i <= 1; i++ ) assertTrue( s.add( i ) );
	assertTrue( s.remove( 0 ) );
	IntIterator iterator = s.iterator();
	assertEquals( 1, iterator.nextInt() );
	assertEquals( -1, iterator.nextInt() );
	assertFalse( iterator.hasNext() );
	
	s = new IntOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = -1; i <= 1; i++ ) assertTrue( s.add( i ) );
	iterator = s.iterator();
	while( iterator.hasNext() ) if ( iterator.nextInt() == 0 ) iterator.remove();
	
	assertFalse( s.contains( 0 ) );
	
	iterator = s.iterator();
	int[] content = new int[ 2 ];
	content[ 0 ] = iterator.nextInt();
	content[ 1 ] = iterator.nextInt();
	assertFalse( iterator.hasNext() );
	Arrays.sort( content );
	assertArrayEquals( new int[] { -1, 1 }, content );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:26,代码来源:IntOpenHashSetTest.java

示例4: testRemove0

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testRemove0() {
	Int2IntLinkedOpenHashMap s = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = -1; i <= 1; i++ ) assertEquals( 0, s.put( i, i ) );
	s.remove( 0 );
	IntIterator iterator = s.keySet().iterator();
	assertEquals( -1, iterator.nextInt() );
	assertEquals( 1, iterator.nextInt() );
	assertFalse( iterator.hasNext() );
	
	s = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = -1; i <= 1; i++ ) assertEquals( 0, s.put( i, i ) );
	iterator = s.keySet().iterator();
	assertEquals( -1, iterator.nextInt() );
	assertEquals( 0, iterator.nextInt() );
	iterator.remove();
	assertEquals( 1, iterator.nextInt() );
	assertFalse( iterator.hasNext() );

	assertFalse( s.containsKey( 0 ) );
	
	iterator = s.keySet().iterator();
	assertEquals( -1, iterator.nextInt() );
	assertEquals( 1, iterator.nextInt() );
	assertFalse( iterator.hasNext() );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:27,代码来源:Int2IntLinkedOpenHashMapTest.java

示例5: testFirtLast0

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testFirtLast0() {
	Int2IntLinkedOpenHashMap s;
	
	s = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 1; i < 100; i++ ) 
		assertEquals( 0, s.put( i, i ) );
	for( int i = 1; i < 100; i++ ) assertEquals( i, s.removeFirstInt() );
	assertTrue( s.isEmpty() );
	
	s = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 0; i < 100; i++ ) assertEquals( 0, s.put( i, i ) );
	for( int i = 100; i-- != 0; ) assertEquals( i, s.removeLastInt() );
	assertTrue( s.isEmpty() );

	s = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 100; i-- != 0; ) assertEquals( 0, s.put( i, i ) );
	for( int i = 0; i < 100; i++ ) assertEquals( i, s.removeLastInt() );
	assertTrue( s.isEmpty() );

	s = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 100; i-- != 0; ) assertEquals( 0, s.put( i, i ) );
	for( int i = 100; i-- != 0; ) assertEquals( i, s.removeFirstInt() );
	assertTrue( s.isEmpty() );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:26,代码来源:Int2IntLinkedOpenHashMapTest.java

示例6: testAddTo

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testAddTo() {
	Int2IntOpenHashMap m = new Int2IntOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	assertEquals( 0, m.addTo( 0, 2 ) );
	assertEquals( 2, m.get( 0 ) );
	assertEquals( 2, m.addTo( 0, 3 ) );
	assertEquals( 5, m.get( 0 ) );
	m.defaultReturnValue( -1 );
	assertEquals( -1, m.addTo( 1, 1 ) );
	assertEquals( 0, m.get( 1 ) );
	assertEquals( 0, m.addTo( 1, 1 ) );
	assertEquals( 1, m.get( 1 ) );
	assertEquals( 1, m.addTo( 1, -2 ) );
	assertEquals( -1, m.get( 1 ) );
	
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:17,代码来源:Int2IntOpenHashMapTest.java

示例7: test1000

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Ignore("Too long")
@Test
public void test1000() throws IOException, ClassNotFoundException {
	test( 1000, Hash.DEFAULT_LOAD_FACTOR );
	test( 1000, Hash.FAST_LOAD_FACTOR );
	test( 1000, Hash.VERY_FAST_LOAD_FACTOR );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:8,代码来源:Object2IntOpenHashMapTest.java

示例8: test1000

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Ignore("Too long")
@Test
public void test1000() {
	test( 1000, Hash.DEFAULT_LOAD_FACTOR );
	test( 1000, Hash.FAST_LOAD_FACTOR );
	test( 1000, Hash.VERY_FAST_LOAD_FACTOR );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:8,代码来源:ObjectOpenHashSetTest.java

示例9: testAdd

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testAdd() {
	IntLinkedOpenHashSet s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	assertTrue( s.add( 0 ) );
	assertTrue( s.contains( 0 ) );
	assertFalse( s.contains( 1 ) );
	assertTrue( s.add( Integer.valueOf( 1 ) ) );
	assertTrue( s.contains( Integer.valueOf( 1 ) ) );
	assertFalse( s.contains( Integer.valueOf( 2 ) ) );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:11,代码来源:IntLinkedOpenHashSetTest.java

示例10: testRemove

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testRemove() {
	IntLinkedOpenHashSet s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 0; i < 100; i++ ) assertTrue( s.add( i ) );
	for( int i = 0; i < 100; i++ ) assertFalse( s.remove( 100 + i ) );
	assertEquals( 0, s.firstInt() );
	assertEquals( 99, s.lastInt() );
	for( int i = 50; i < 150; i++ ) assertTrue( Integer.toString( i % 100 ), s.remove( i % 100 ) );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:10,代码来源:IntLinkedOpenHashSetTest.java

示例11: testPutAndMove

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testPutAndMove() {
	IntLinkedOpenHashSet s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 0; i < 100; i++ ) assertTrue( s.addAndMoveToFirst( i ) );
	s.clear();
	for( int i = 0; i < 100; i++ ) assertTrue( s.addAndMoveToLast( i ) );
	assertTrue( s.addAndMoveToFirst( -1 ) );
	assertEquals( -1, s.firstInt() );
	assertTrue( s.addAndMoveToFirst( -2 ) );
	assertEquals( -2, s.firstInt() );
	assertFalse( s.addAndMoveToFirst( -1 ) );
	assertEquals( -1, s.firstInt() );
	assertFalse( s.addAndMoveToFirst( -1 ) );
	assertEquals( -1, s.firstInt() );
	assertFalse( s.addAndMoveToLast( -1 ) );
	assertEquals( -1, s.lastInt() );
	assertTrue( s.addAndMoveToLast( 100 ) );
	assertEquals( 100, s.lastInt() );
	assertTrue( s.addAndMoveToLast( 101 ) );
	assertEquals( 101, s.lastInt() );
	assertFalse( s.addAndMoveToLast( 100 ) );
	assertEquals( 100, s.lastInt() );
	assertFalse( s.addAndMoveToLast( 100 ) );
	assertEquals( 100, s.lastInt() );
	assertFalse( s.addAndMoveToFirst( 100 ) );
	assertEquals( 100, s.firstInt() );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:28,代码来源:IntLinkedOpenHashSetTest.java

示例12: testRemoveFirstLast

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testRemoveFirstLast() {
	IntLinkedOpenHashSet s = new IntLinkedOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 0; i < 100; i++ ) assertTrue( s.add( i ) );
	assertEquals( 0, s.removeFirstInt() );
	assertEquals( 1, s.removeFirstInt() );
	assertEquals( 99, s.removeLastInt() );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:9,代码来源:IntLinkedOpenHashSetTest.java

示例13: testRemove

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testRemove() {
	IntOpenHashSet s = new IntOpenHashSet( Hash.DEFAULT_INITIAL_SIZE );
	for( int i = 0; i < 100; i++ ) assertTrue( s.add( i ) );
	for( int i = 0; i < 100; i++ ) assertFalse( s.remove( 100 + i ) );
	for( int i = 50; i < 150; i++ ) assertTrue( Integer.toString( i % 100 ), s.remove( i % 100 ) );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:8,代码来源:IntOpenHashSetTest.java

示例14: testAddTo

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testAddTo() {
	Int2IntLinkedOpenHashMap m = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	assertEquals( 0, m.addTo( 0, 2 ) );
	assertEquals( 2, m.get( 0 ) );
	assertEquals( 2, m.addTo( 0, 3 ) );
	assertEquals( 5, m.get( 0 ) );
	ObjectIterator<Int2IntMap.Entry> fastIterator = m.int2IntEntrySet().fastIterator();
	Int2IntMap.Entry next = fastIterator.next();
	assertEquals( 0, next.getIntKey() );
	assertEquals( 5, next.getIntValue() );
	assertFalse( fastIterator.hasNext() );
	
	m.defaultReturnValue( -1 );
	assertEquals( -1, m.addTo( 1, 1 ) );
	assertEquals( 0, m.get( 1 ) );
	assertEquals( 0, m.addTo( 1, 1 ) );
	assertEquals( 1, m.get( 1 ) );
	assertEquals( 1, m.addTo( 1, -2 ) );
	assertEquals( -1, m.get( 1 ) );
	fastIterator = m.int2IntEntrySet().fastIterator();
	next = fastIterator.next();
	assertEquals( 0, next.getIntKey() );
	assertEquals( 5, next.getIntValue() );
	next = fastIterator.next();
	assertEquals( 1, next.getIntKey() );
	assertEquals( -1, next.getIntValue() );
	assertFalse( fastIterator.hasNext() );
	
	for( int i = 0; i < 100; i++ ) m.addTo( i, 1 );
	assertEquals( 0, m.firstIntKey() );
	assertEquals( 99, m.lastIntKey() );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:34,代码来源:Int2IntLinkedOpenHashMapTest.java

示例15: testPut

import it.unimi.dsi.fastutil.Hash; //导入依赖的package包/类
@Test
public void testPut() {
	Int2IntLinkedOpenHashMap m = new Int2IntLinkedOpenHashMap( Hash.DEFAULT_INITIAL_SIZE );
	assertEquals( 0, m.put( 0, 2 ) );
	assertEquals( 2, m.put( 0, 3 ) );
	assertEquals( 3, m.get( 0 ) );
	assertEquals( null, m.put( Integer.valueOf( 1 ), Integer.valueOf( 2 ) ) );
	assertEquals( Integer.valueOf( 2 ), m.put( Integer.valueOf( 1 ), Integer.valueOf( 3 ) ) );
	assertEquals( Integer.valueOf( 3 ), m.get( Integer.valueOf( 0 ) ) );
}
 
开发者ID:phishman3579,项目名称:fastutil,代码行数:11,代码来源:Int2IntLinkedOpenHashMapTest.java


注:本文中的it.unimi.dsi.fastutil.Hash类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。