public void addToSuccessfulBuckets(int bId) { this.successfulBuckets.add(bId); }
public void setBucketList(List list) { this.bucketList = list; this.successfulBuckets = new TIntHashSet(); }
/** * Creates an iterator over the values of the set. * * @return an iterator with support for removals in the underlying set */ @Override // GemStoneAddition public Iterator iterator() { return new Iterator() { private final TIntIterator it = _set.iterator(); public Object next() { return wrap(it.next()); } public boolean hasNext() { return it.hasNext(); } public void remove() { it.remove(); } }; }
/** * Compares this set with another set for equality of their stored * entries. * * @param other an <code>Object</code> value * @return a <code>boolean</code> value */ @Override // GemStoneAddition public boolean equals(Object other) { if (! (other instanceof TIntHashSet)) { return false; } final TIntHashSet that = (TIntHashSet)other; if (that.size() != this.size()) { return false; } return forEach(new TIntProcedure() { public final boolean execute(int value) { return that.contains(value); } }); }
public void DEBUG_testArraySorting() { for (int c = 1; c <= 4; c++) { TIntHashSet randInts = new TIntHashSet(numItems); final String[] values = new String[numItems]; for (int i = 0; i < numItems; i++) { int rnd = PartitionedRegion.rand.nextInt(numItems); randInts.add(rnd); values[i] = "strkey-" + rnd; randInts.remove(suffix); fail("inserted " + numItems + " but got " + n); if ((c % 2) == 1 && !randInts.isEmpty()) { fail("did not get all elements in result for ints: " + randInts.toString());
TIntObjectHashMapWithDups dupsMap = new TIntObjectHashMapWithDups( duplicateObserver, ObjectEqualsHashingStrategy.getInstance()); TIntHashSet vals = new TIntHashSet(); if (vals.contains(i % 50)) { assertEquals(i % 50, existing); vals.add(i % 50); assertEquals(vals.size(), dupsMap.size());
TIntHashSet exceptions = new TIntHashSet(); for(int i =0; i < NUM_EXCEPTIONS; i++) { exceptions.add(i); assertEquals("vector is incorrect on item "+ i,!exceptions.contains(i), vh1.contains(i)); assertEquals("vector is incorrect on item "+ i,!exceptions.contains(i), vh2.contains(i));
if (_set.equals(other)) { return true; // comparing two trove sets } else if (other instanceof Set) { Set that = (Set)other; if (that.size() != _set.size()) { return false; // different sizes, no need to compare } else { // now we have to do it the hard way if (val instanceof Integer) { int v = unwrap(val); if (_set.contains(v)) {
public final boolean execute(int value) { return that.contains(value); } });
/** * Removes all of the elements in <tt>array</tt> from the set. * * @param array an <code>array</code> of int primitives. * @return true if the set was modified by the remove all operation. */ public boolean removeAll(int[] array) { boolean changed = false; for (int i = array.length; i-- > 0;) { if (remove(array[i])) { changed = true; } } return changed; }
/** * Returns the number of entries in the set. * @return the set's size. */ @Override // GemStoneAddition public int size() { return this._set.size(); }
for (int c = 1; c <= 4; c++) { TIntHashSet randInts = new TIntHashSet(numItems); final String[] values = new String[numItems]; for (int i = 0; i < numItems; i++) { int rnd = PartitionedRegion.rand.nextInt(numItems); randInts.add(rnd); values[i] = "strkey-" + rnd; randInts.remove(suffix); fail("inserted " + numItems + " but got " + n); if ((c % 2) == 1 && !randInts.isEmpty()) { fail("did not get all elements in result for ints: " + randInts.toString());
/** * Tests the set to determine if all of the elements in * <tt>array</tt> are present. * * @param array an <code>array</code> of int primitives. * @return true if all elements were present in the set. */ public boolean containsAll(int[] array) { for (int i = array.length; i-- > 0;) { if (! contains(array[i])) { return false; } } return true; }
/** * Removes any values in the set which are not contained in * <tt>array</tt>. * * @param array an <code>array</code> of int primitives. * @return true if the set was modified by the retain all operation */ public boolean retainAll(int[] array) { boolean changed = false; Arrays.sort(array); int[] set = _set; byte[] states = _states; for (int i = set.length; i-- > 0;) { if (states[i] == FULL && (Arrays.binarySearch(array,set[i]) < 0)) { remove(set[i]); changed = true; } } return changed; }
/** * Returns a new array containing the values in the set. * * @return an <code>int[]</code> value */ public int[] toArray() { int[] result = new int[size()]; int[] set = _set; byte[] states = _states; for (int i = states.length, j = 0; i-- > 0;) { if (states[i] == FULL) { result[j++] = set[i]; } } return result; }
/** * Adds all of the elements in <tt>array</tt> to the set. * * @param array an <code>array</code> of int primitives. * @return true if the set was modified by the add all operation. */ public boolean addAll(int[] array) { boolean changed = false; for (int i = array.length; i-- > 0;) { if (add(array[i])) { changed = true; } } return changed; }
/** * Construct a PartitionedRegionQueryEvaluator * @param sys the distributed system * @param pr the partitioned region * @param query the query * @param parameters the parameters for executing the query * @param cumulativeResults where to add the results as they come in */ public PartitionedRegionQueryEvaluator(InternalDistributedSystem sys, PartitionedRegion pr, DefaultQuery query, Object[] parameters, SelectResults cumulativeResults, Set<Integer> bucketsToQuery) { super(sys, pr.getPRId()); this.pr = pr; this.query = query; this.parameters = parameters; this.cumulativeResults = cumulativeResults; this.bucketsToQuery = bucketsToQuery; this.successfulBuckets = new TIntHashSet(this.bucketsToQuery.size()); this.resultsPerMember = new ConcurrentHashMap<InternalDistributedMember, Collection<Collection>>(); this.node2bucketIds = Collections.EMPTY_MAP; }
TIntIterator ti = dependentCols.iterator(); while (ti.hasNext()) {
@Override public void run() { //This thread will record updates for this single thread. The //update is the thread id * the update number for(int i =myNumber; i < updates; i+= numUpdaters) { //Only apply the update if it is not an intended exception if(!exceptions.contains(i)) { synchronized(vh1) { vh1.recordVersion(i, null); } //Apply only half the updates to vh2. We will then mimic a GII if(i < updates /2) { synchronized(vh2) { vh2.recordVersion(i, null); } } Thread.yield(); } } }