@Override public Long next() { synchronized (ColtLongHashSet.this) { if (versionSnapshot != version) { throw new ConcurrentModificationException(); } if (index >= mapKeyList.size()) { throw new NoSuchElementException(); } long value = mapKeyList.getQuick(index); index++; canRemove = true; return value; } }
public boolean apply(long key) { list.add(key); return true; } }
/** * Constructs a list containing the specified elements. * The initial size and capacity of the list is the length of the array. * * <b>WARNING:</b> For efficiency reasons and to keep memory usage low, <b>the array is not copied</b>. * So if subsequently you modify the specified array directly via the [] operator, be sure you know what you're doing. * * @param elements the array to be backed by the the constructed list */ public LongArrayList(long[] elements) { elements(elements); } /**
int j=0; long[] theElements = elements; int mySize = size(); sortedList.quickSort(); if (sortedList.binarySearchFromTo(theElements[i], 0, limit) >= 0) theElements[j++]=theElements[i]; setSize(j); return modified;
/** * Compares the specified Object with the receiver. * Returns true if and only if the specified Object is also an ArrayList of the same type, both Lists have the * same size, and all corresponding pairs of elements in the two Lists are identical. * In other words, two Lists are defined to be equal if they contain the * same elements in the same order. * * @param otherObj the Object to be compared for equality with the receiver. * @return true if the specified Object is equal to the receiver. */ public boolean equals(Object otherObj) { //delta // overridden for performance only. if (! (otherObj instanceof LongArrayList)) return super.equals(otherObj); if (this==otherObj) return true; if (otherObj==null) return false; LongArrayList other = (LongArrayList) otherObj; if (size()!=other.size()) return false; long[] theElements = elements(); long[] otherElements = other.elements(); for (int i=size(); --i >= 0; ) { if (theElements[i] != otherElements[i]) return false; } return true; } /**
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by value, according to natural ordering. */ public String toStringByValue() { LongArrayList theKeys = new LongArrayList(); keysSortedByValue(theKeys); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { long key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); } /**
/** * Fills all keys and values <i>sorted ascending by key</i> into the specified lists. * Fills into the lists, starting at index 0. * After this call returns the specified lists both have a new size that equals <tt>this.size()</tt>. * <p> * <b>Example:</b> * <br> * <tt>keys = (8,7,6), values = (1,2,2) --> keyList = (6,7,8), valueList = (2,2,1)</tt> * * @param keyList the list to be filled with keys, can have any size. * @param valueList the list to be filled with values, can have any size. */ public void pairsSortedByKey(final LongArrayList keyList, final ObjectArrayList valueList) { keys(keyList); keyList.sort(); valueList.setSize(keyList.size()); for (int i=keyList.size(); --i >= 0; ) { valueList.setQuick(i,get(keyList.getQuick(i))); } } /**
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { LongArrayList theKeys = keys(); theKeys.sort(); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { long key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); } /**
int tiersCount = tiers.size(); if (tiersCount < 2) toBeRemoved.add(key); long formulaAndTierIndex = tiers.getQuick(0); long formulaIndexPart = formulaAndTierIndex & 0xFFFFFFFF00000000L; for (int i = 1; i < tiersCount; i++) long formulaAndTierIndex2 = tiers.getQuick(i); long formulaIndexPart2 = formulaAndTierIndex2 & 0xFFFFFFFF00000000L; if (formulaIndexPart != formulaIndexPart2) toBeRemoved.add(key);
final LongArrayList toBeRemoved = new LongArrayList(); int size = toBeRemoved.size(); for (int i = 0; i < size; i++) long key = toBeRemoved.getQuick(i); pairsToTiersIndex.removeKey(key);
private void addVarNamePair(int varName1, long key) { LongArrayList pairs = (LongArrayList) varNameToPairsIndex.get(varName1); if (pairs == null) { pairs = new LongArrayList(new long[]{ key }); varNameToPairsIndex.put(varName1, pairs); } else { pairs.add(key); } } });
/** * Replaces a number of elements in the receiver with the same number of elements of another list. * Replaces elements in the receiver, between <code>from</code> (inclusive) and <code>to</code> (inclusive), * with elements of <code>other</code>, starting from <code>otherFrom</code> (inclusive). * * @param from the position of the first element to be replaced in the receiver * @param to the position of the last element to be replaced in the receiver * @param other list holding elements to be copied into the receiver. * @param otherFrom position of first element within other list to be copied. */ public void replaceFromToWithFrom(int from, int to, AbstractLongList other, int otherFrom) { // overridden for performance only. if (! (other instanceof LongArrayList)) { // slower super.replaceFromToWithFrom(from,to,other,otherFrom); return; } int length=to-from+1; if (length>0) { checkRangeFromTo(from, to, size()); checkRangeFromTo(otherFrom,otherFrom+length-1,other.size()); System.arraycopy(((LongArrayList) other).elements, otherFrom, elements, from, length); } } /**
checkRangeFromTo(from, to, size); countSortFromTo(from, to, min, max); quickSortFromTo(from, to);
@Override public boolean hasNext() { synchronized (ColtLongHashSet.this) { return index < mapKeyList.size(); } }
/** * Sets the receiver's elements to be the specified array. * The size and capacity of the list is the length of the array. * <b>WARNING:</b> For efficiency reasons and to keep memory usage low, this method may decide <b>not to copy the array</b>. * So if subsequently you modify the returned array directly via the [] operator, be sure you know what you're doing. * * @param elements the new elements to be stored. * @return the receiver itself. */ public AbstractLongList elements(long[] elements) { clear(); addAllOfFromTo(new LongArrayList(elements),0,elements.length-1); return this; } /**
/** * Returns a deep copy of the receiver. * * @return a deep copy of the receiver. */ public Object clone() { // overridden for performance only. LongArrayList clone = new LongArrayList((long[]) elements.clone()); clone.setSizeRaw(size); return clone; } /**
/** * Returns a new list of the part of the receiver between <code>from</code>, inclusive, and <code>to</code>, inclusive. * @param from the index of the first element (inclusive). * @param to the index of the last element (inclusive). * @return a new list * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public AbstractLongList partFromTo(int from, int to) { if (size==0) return new LongArrayList(0); checkRangeFromTo(from, to, size); long[] part = new long[to-from+1]; System.arraycopy(elements, from, part, 0, to-from+1); return new LongArrayList(part); } /**
/** * Returns a new list of the part of the receiver between <code>from</code>, inclusive, and <code>to</code>, inclusive. * @param from the index of the first element (inclusive). * @param to the index of the last element (inclusive). * @return a new list * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public AbstractLongList partFromTo(int from, int to) { checkRangeFromTo(from, to, size); int length = to-from+1; LongArrayList part = new LongArrayList(length); part.addAllOfFromTo(this,from,to); return part; } /**
/** * Fills all keys contained in the receiver into the specified list. * Fills the list, starting at index 0. * After this call returns the specified list has a new size that equals <tt>this.size()</tt>. * Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(LongProcedure)}. * <p> * This method can be used to iterate over the keys of the receiver. * * @param list the list to be filled, can have any size. */ public void keys(LongArrayList list) { list.setSize(distinct); long[] elements = list.elements(); long[] tab = table; byte[] stat = state; int j=0; for (int i = tab.length ; i-- > 0 ;) { if (stat[i]==FULL) elements[j++]=tab[i]; } } /**