@Override public synchronized boolean add(Long aLong) { version++; return map.put(aLong, TRUE); }
public ColtHashSet( int initialCapacity, double minLoadFactor, double maxLoadFactor ) { map = new OpenLongObjectHashMap( initialCapacity, minLoadFactor, maxLoadFactor ); }
@Override public synchronized int size() { return map.size(); }
int i = indexOfInsertion(key); if (i<0) { //already contained i = -i -1; int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity); return put(key, value); int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity);
/** * Trims the capacity of the receiver to be the receiver's current * size. Releases any superfluous internal memory. An application can use this operation to minimize the * storage of the receiver. */ public void trimToSize() { // * 1.2 because open addressing's performance exponentially degrades beyond that point // so that even rehashing the table can take very long int newCapacity = nextPrime((int)(1 + 1.2*size())); if (table.length > newCapacity) { rehash(newCapacity); } } /**
/** * Removes the given key with its associated element from the receiver, if present. * * @param key the key to be removed from the receiver. * @return <tt>true</tt> if the receiver contained the specified key, <tt>false</tt> otherwise. */ public boolean removeKey(long key) { int i = indexOfKey(key); if (i<0) return false; // key not contained this.state[i]=REMOVED; this.values[i]=null; // delta this.distinct--; if (this.distinct < this.lowWaterMark) { int newCapacity = chooseShrinkCapacity(this.distinct,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity); } return true; } /**
byte newState[] = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity,this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity,this.maxLoadFactor); if (oldState[i]==FULL) { long element = oldTable[i]; int index = indexOfInsertion(element); newTable[index]=element; newValues[index]=oldValues[i];
private void addVarName(int varName) { LongArrayList pairs = fullIndex.getPairs(varName); if (pairs == null) { // There is no any pairs that contain this varName. // No need to add it to the index. return; } for (int i = 0; i < pairs.size(); i++) { long key = pairs.getQuick(i); if (!pairsToTiersIndex.containsKey(key)) { pairsToTiersIndex.put(key, fullIndex.pairsToTiersIndex.get(key)); } } } }
/** * Creates copy of <code>formula</code>. * * New formula uses the same instance of <code>permutation</code> and cloned instances of tiers. * Be careful about modifying permutation of new formula, because these changes will also affect initial formula. * * @param formula */ private SimpleFormula(SimpleFormula formula, final boolean fillTiersHash3) { this.permutation = formula.permutation; int tiersCount = formula.tiers.size(); this.tiers = new ObjectArrayList(tiersCount); this.tiersHash3 = fillTiersHash3 ? new OpenLongObjectHashMap(tiersCount) : null; Object[] tiersElements = formula.tiers.elements(); for (int i = 0; i < tiersCount; i++) { ITier clone = ((ITier) tiersElements[i]).clone(); tiers.add(clone); if (fillTiersHash3) { tiersHash3.put(clone.canonicalHashCode(), clone); } } }
private void addTiersHash2(ITier tier, int varName1, int varName2) { long key = varName1 < varName2 ? (long)varName1 << 21 | varName2 : (long)varName2 << 21 | varName1; ObjectArrayList tiers = (ObjectArrayList) tiersHash2.get(key); if (tiers == null) { tiersHash2.put(key, new ObjectArrayList(new ITier[] {tier})); } else { tiers.add(tier); } }
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity==0) capacity=1; // open addressing needs at least one FREE slot at any time. this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);
/** * Returns <tt>true</tt> if the receiver contains the specified key. * * @return <tt>true</tt> if the receiver contains the specified key. */ public boolean containsKey(long key) { return indexOfKey(key) >= 0; } /**
/** * Returns <tt>true</tt> if the receiver contains the specified value. * * @return <tt>true</tt> if the receiver contains the specified value. */ public boolean containsValue(Object value) { return indexOfValue(value) >= 0; } /**
int i = indexOfInsertion(key); if (i<0) { //already contained i = -i -1; int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity); return put(key, value); int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity);
/** * Trims the capacity of the receiver to be the receiver's current * size. Releases any superfluous internal memory. An application can use this operation to minimize the * storage of the receiver. */ public void trimToSize() { // * 1.2 because open addressing's performance exponentially degrades beyond that point // so that even rehashing the table can take very long int newCapacity = nextPrime((int)(1 + 1.2*size())); if (table.length > newCapacity) { rehash(newCapacity); } } /**
/** * Removes the given key with its associated element from the receiver, if present. * * @param key the key to be removed from the receiver. * @return <tt>true</tt> if the receiver contained the specified key, <tt>false</tt> otherwise. */ public boolean removeKey(long key) { int i = indexOfKey(key); if (i<0) return false; // key not contained this.state[i]=REMOVED; this.values[i]=null; // delta this.distinct--; if (this.distinct < this.lowWaterMark) { int newCapacity = chooseShrinkCapacity(this.distinct,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity); } return true; } /**
byte newState[] = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity,this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity,this.maxLoadFactor); if (oldState[i]==FULL) { long element = oldTable[i]; int index = indexOfInsertion(element); newTable[index]=element; newValues[index]=oldValues[i];
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity==0) capacity=1; // open addressing needs at least one FREE slot at any time. this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);
/** * Returns <tt>true</tt> if the receiver contains the specified key. * * @return <tt>true</tt> if the receiver contains the specified key. */ public boolean containsKey(long key) { return indexOfKey(key) >= 0; } /**