本文整理匯總了Java中gnu.trove.set.hash.TIntHashSet類的典型用法代碼示例。如果您正苦於以下問題:Java TIntHashSet類的具體用法?Java TIntHashSet怎麽用?Java TIntHashSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TIntHashSet類屬於gnu.trove.set.hash包,在下文中一共展示了TIntHashSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AgreeSets
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public AgreeSets(MaximalEquivalenceClasses maximalEquivalenceClasses, EquivalenceClasses equivalenceClasses, int numberOfColumns, int numberOfRows) {
TIntHashSet[] comparedCouples = new TIntHashSet[numberOfRows];
for (int i = 0; i < comparedCouples.length; i++) {
comparedCouples[i] = new TIntHashSet();
}
for (TEquivalence equivalenceGroup : maximalEquivalenceClasses) {
int[] equivalenceGroupArray = equivalenceGroup.toArray();
// generate all 2-tuples based on the current equivalence class
for (int outerIndex = 0; outerIndex < equivalenceGroup.size()-1; outerIndex++) {
for (int innerIndex = outerIndex+1; innerIndex < equivalenceGroup.size(); innerIndex++) {
// make sure that you don't check the same couples more than one time
// needs too much space for most datasets
// if (!comparedCouples[outerIndex].contains(innerIndex)) {
// comparedCouples[outerIndex].add(innerIndex);
//
// create a couple consisting of tuple t and tuple t'
EquivalenceClass equivalenceClassTupleT = equivalenceClasses.get(equivalenceGroupArray[outerIndex]);
EquivalenceClass equivalenceClassTupleTPrime = equivalenceClasses.get(equivalenceGroupArray[innerIndex]);
AgreeSet agreeSet = new AgreeSet(equivalenceClassTupleT, equivalenceClassTupleTPrime, numberOfColumns);
this.add(agreeSet);
// }
}
}
}
}
示例2: TargetRegisterClass
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
protected TargetRegisterClass(int id,
String name,
EVT[] vts,
TargetRegisterClass[] subcs,
TargetRegisterClass[] supercs,
TargetRegisterClass[] subregcs,
TargetRegisterClass[] superregcs,
int regsz, int regAlign,
int copyCost,
int[] regs)
{
this.id = id;
this.name = name;
this.vts = vts;
subClasses = subcs;
superClasses = supercs;
subRegClasses = subregcs;
superRegClasses = superregcs;
regSize = regsz;
this.regAlign = regAlign;
this.regs = regs;
this.copyCost = copyCost;
regSet = new TIntHashSet();
regSet.addAll(regs);
}
示例3: distinct
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
@Override
public final Array<Integer> distinct(int limit) {
final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
final TIntSet set = new TIntHashSet(capacity);
final ArrayBuilder<Integer> builder = ArrayBuilder.of(capacity, Integer.class);
for (int i=0; i<length(); ++i) {
final int value = getInt(i);
if (set.add(value)) {
builder.addInt(value);
if (set.size() >= limit) {
break;
}
}
}
return builder.toArray();
}
示例4: distinct
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
@Override
public Array<T> distinct(int limit) {
final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
final TIntSet set = new TIntHashSet(capacity);
final ArrayBuilder<T> builder = ArrayBuilder.of(capacity, type());
for (int i=0; i<length(); ++i) {
final int code = getInt(i);
if (set.add(code)) {
final T value = getValue(i);
builder.add(value);
if (set.size() >= limit) {
break;
}
}
}
return builder.toArray();
}
示例5: seekOrCreateClazz
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
private Clazz seekOrCreateClazz(final String fullQName, final Application application,
final TIntHashSet objectIds) {
final String[] splittedName = fullQName.split("\\.");
Map<String, Clazz> appCached = clazzCache.get(application);
if (appCached == null) {
appCached = new HashMap<String, Clazz>();
clazzCache.put(application, appCached);
}
Clazz clazz = appCached.get(fullQName);
if (clazz == null) {
clazz = seekrOrCreateClazzHelper(fullQName, splittedName, application, null, 0);
appCached.put(fullQName, clazz);
}
if (objectIds != null) {
final TIntIterator iterator = objectIds.iterator();
while (iterator.hasNext()) {
clazz.getObjectIds().add(iterator.next());
}
clazz.setInstanceCount(clazz.getObjectIds().size());
}
return clazz;
}
示例6: testKeySetHashCode
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testKeySetHashCode() {
int element_count = 20;
int[] keys = new int[element_count];
String[] vals = new String[element_count];
TIntObjectMap<String> map = new TIntObjectHashMap<String>();
for ( int i = 0; i < element_count; i++ ) {
keys[i] = i + 1;
vals[i] = Integer.toString( i + 1 );
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
TIntSet keyset = map.keySet();
for ( int i = 0; i < keyset.size(); i++ ) {
assertTrue( keyset.contains( keys[i] ) );
}
assertFalse( keyset.isEmpty() );
assertEquals( keyset.hashCode(), keyset.hashCode() );
TIntSet other = new TIntHashSet( keys );
other.add( 1138 );
assertTrue( keyset.hashCode() != other.hashCode() );
}
示例7: testEquals
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testEquals() {
int element_count = 20;
TIntList list = new TIntArrayList();
for ( int i = 1; i <= element_count; i++ ) {
list.add( i );
}
assertEquals( list, list );
assertEquals( list, new TIntArrayList( list ) );
TIntCollection collection = new TIntHashSet();
for ( int i = 1; i <= element_count; i++ ) {
collection.add( i );
}
assertFalse( list.equals( collection ) );
collection.add( 1138 );
assertFalse( list.equals( collection ) );
TIntList other = new TIntArrayList( list );
other.replace( 10, 1138 );
assertFalse( list.equals( other ) );
}
示例8: testEquals
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testEquals() {
int element_count = 20;
TIntList list = new TIntLinkedList();
for ( int i = 1; i <= element_count; i++ ) {
list.add( i );
}
assertEquals( list, list );
assertEquals( list, new TIntLinkedList( list ) );
TIntCollection collection = new TIntHashSet();
for ( int i = 1; i <= element_count; i++ ) {
collection.add( i );
}
assertFalse( list.equals( collection ) );
collection.add( 1138 );
assertFalse( list.equals( collection ) );
TIntList other = new TIntLinkedList( list );
other.replace( 10, 1138 );
assertFalse( list.equals( other ) );
}
示例9: testSerialize
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testSerialize() throws Exception {
Integer[] ints = {1138, 42, 86, 99, 101};
TIntSet raw_set = new TIntHashSet();
Set<Integer> set = TDecorators.wrap( raw_set );
set.addAll( Arrays.asList( ints ) );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( set );
ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() );
ObjectInputStream ois = new ObjectInputStream( bias );
//noinspection unchecked
Set<Integer> deserialized = ( Set<Integer> ) ois.readObject();
assertEquals( set, deserialized );
}
示例10: testToArray
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testToArray() {
TIntSet raw_set = new TIntHashSet();
Set<Integer> set = TDecorators.wrap( raw_set );
Integer[] ints = {42, 1138, 13, 86, 99};
set.addAll( Arrays.asList( ints ) );
Object[] obj_res = set.toArray();
Arrays.sort( ints );
Arrays.sort( obj_res );
assertTrue( Arrays.equals( ints, obj_res ) );
Object[] res = set.toArray();
Arrays.sort( ints );
Arrays.sort( res );
assertTrue( Arrays.equals( ints, res ) );
res = set.toArray( new Integer[set.size()] );
Arrays.sort( ints );
Arrays.sort( res );
assertTrue( Arrays.equals( ints, res ) );
}
示例11: testToArrayMatchesIteratorOrder
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testToArrayMatchesIteratorOrder() {
TIntSet raw_set = new TIntHashSet();
Set<Integer> set = TDecorators.wrap( raw_set );
Integer[] ints = {42, 1138, 13, 86, 99};
set.addAll( Arrays.asList( ints ) );
Integer[] toarray_ints = set.toArray( new Integer[ints.length] );
Integer[] iter_ints = new Integer[ints.length];
Iterator<Integer> iter = set.iterator();
int index = 0;
while ( iter.hasNext() ) {
iter_ints[index++] = iter.next();
}
assertTrue( Arrays.equals( iter_ints, toarray_ints ) );
}
示例12: testToArrayWithParams
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testToArrayWithParams() {
int no_entry_value = Integer.MIN_VALUE;
TIntSet raw_set = new TIntHashSet( 10, 0.5f, no_entry_value );
Set<Integer> set = TDecorators.wrap( raw_set );
Integer[] ints = {42, 1138, 13, 86, 99};
set.addAll( Arrays.asList( ints ) );
Integer[] sink = new Integer[ints.length + 2];
sink[sink.length - 1] = -1;
sink[sink.length - 2] = -2;
Integer[] res = set.toArray( sink );
assertNull( res[set.size()] );
Set<Integer> copy = new HashSet<Integer>();
copy.addAll( Arrays.asList( sink ) );
Set<Integer> bogey = new HashSet<Integer>();
bogey.addAll( Arrays.asList( ints ) );
bogey.add( -1 );
bogey.add( null );
assertEquals( bogey, copy );
}
示例13: testHashcode
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
public void testHashcode() {
int[] ints = {1138, 42, 86, 99, 101};
TIntSet raw_set = new TIntHashSet();
raw_set.addAll( ints );
Set<Integer> set = TDecorators.wrap( raw_set );
TIntSet raw_other = new TIntHashSet();
raw_other.addAll( ints );
Set<Integer> other = TDecorators.wrap( raw_other );
assertTrue( "hashcodes incorrectly not equal: " + set + ", " + other,
set.hashCode() == other.hashCode() );
int[] mismatched = {72, 49, 53, 1024, 999};
TIntSet unequal = new TIntHashSet();
unequal.addAll( mismatched );
assertFalse( "hashcodes unlikely equal: " + set + ", " + unequal,
set.hashCode() == unequal.hashCode() );
}
示例14: getRatings_shouldReturnAllRatingsOfUser
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
@Test
public void getRatings_shouldReturnAllRatingsOfUser() {
TIntSet itemTypeIds = new TIntHashSet(new int[]{1});
List<RatingVO<Integer, Integer>> ratings = actionDAO.getRatings(1, itemTypeIds, 1);
assertThat(ratings.size(), is(4));
assertThat(ratings, hasItem(equalTo(createRating(1, 1, 1, "2007-04-15 12:11:00.0"))));
assertThat(ratings, hasItem(equalTo(createRating(2, 1, 2, "2007-04-15 12:12:00.0"))));
assertThat(ratings, hasItem(equalTo(createRating(3, 1, 3, "2007-04-15 12:13:00.0"))));
assertThat(ratings, hasItem(equalTo(createRating(4, 1, 4, "2007-04-15 12:14:00.0"))));
ratings = actionDAO.getRatings(1, itemTypeIds, 2);
assertThat(ratings.size(), is(1));
assertThat(ratings, hasItem(equalTo(createRating(7, 2, 7, "2007-04-15 12:17:00.0"))));
}
示例15: initialize
import gnu.trove.set.hash.TIntHashSet; //導入依賴的package包/類
@Override
public void initialize(Timestamp timestamp) {
this.timestamp = Revision.compressTime(timestamp.getTime());
/**
* filled in revisions
*/
pageIdRevMap = new HashMap<Integer, Long>();
textIdPageIdMap = new TIntIntHashMap();
/**
* filled in pages
*/
pPageIdNameMap = new HashMap<Integer, String>();
pNamePageIdMap = new TIntIntHashMap();
cNamePageIdMap = new TIntIntHashMap();
rPageIdNameMap = new HashMap<Integer, String>();
/**
* filled in categories
*/
disambiguations = new TIntHashSet();
}