@Override public void remove() { synchronized (ColtIntegerHashSet.this) { if (!canRemove) { throw new IllegalStateException( "repeated remove() calls or next() not called" ); } map.removeKey(mapKeyList.get(index - 1)); canRemove = false; version++; versionSnapshot = version; } } }
@Override public boolean hasNext() { synchronized (ColtIntegerHashSet.this) { return index < mapKeyList.size(); } }
/** * Constructs and returns a new buffer with the given target. * @param target the target to flush to. * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target. */ public IntBuffer(IntBufferConsumer target, int capacity) { this.target = target; this.capacity = capacity; this.elements = new int[capacity]; this.list = new IntArrayList(elements); this.size = 0; } /**
@Override public Long next() { synchronized (ColtIntegerHashSet.this) { if (versionSnapshot != version) { throw new ConcurrentModificationException(); } if (index >= mapKeyList.size()) { throw new NoSuchElementException(); } long value = mapKeyList.getQuick(index); index++; canRemove = true; return value; } }
/** * Part of interface contract */ public int[] getNodeIndicesArray() { giny_nodes.trimToSize(); return giny_nodes.elements(); }
/** * Equivalent to <tt>partition(list.elements(), from, to, splitters.elements(), 0, splitters.size()-1, splitIndexes.elements())</tt>. */ public static void partition(IntArrayList list, int from, int to, IntArrayList splitters, IntArrayList splitIndexes) { partition(list.elements(),from,to,splitters.elements(),0,splitters.size()-1,splitIndexes.elements()); } /**
public List<ConceptData> getConceptDataList(DoubleMatrix1D v1){ IntArrayList arg0 = new IntArrayList() ; DoubleArrayList arg1=new DoubleArrayList(); v1.getNonZeros(arg0, arg1); List<ConceptData> vectorTopic=new ArrayList<ConceptData>() ; for(int i=0;i<arg0.size();i++){ String concept=inverseindex.get(arg0.get(i)); ConceptData data=new ConceptData(concept,arg1.get(i)); vectorTopic.add(data); } return vectorTopic; }
/** * 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 IntArrayList 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))); } } /**
/** * 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 IntArrayList keyList, final IntArrayList valueList) { keys(keyList); keyList.sort(); valueList.setSize(keyList.size()); for (int i=keyList.size(); --i >= 0; ) { valueList.setQuick(i,get(keyList.getQuick(i))); } } /**
protected double productQuick(DoubleMatrix1D v1, DoubleMatrix1D v2) { IntArrayList indexList = new IntArrayList(); DoubleArrayList valueList = new DoubleArrayList(); v1.getNonZeros(indexList, valueList); double prod = 0.0; for (int i = 0; i < indexList.size(); ++i) { double temp = v2.getQuick(indexList.getQuick(i)); if (temp != 0.0) { prod += valueList.getQuick(i) * temp; } } // double prod = 0.0; // for (int i = 0; i < v1.size(); ++i) { // double temp1 = v1.getQuick(i); // double temp2 = v2.getQuick(i); // if (temp1 != 0.0 || temp2 != 0.0) { // prod += temp1 * temp2; // } // } return prod; }
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); theKeys.sort(); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int 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(); } /**
/** * DOCUMENT ME! * * @return DOCUMENT ME! */ public int[] getEdgeIndicesArray() { final IntArrayList edge_indices = new IntArrayList(edges.size()); edges.keys(edge_indices); edge_indices.trimToSize(); return edge_indices.elements(); }
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); //theKeys.sort(); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int 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 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(IntProcedure)}. * <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(IntArrayList list) { list.setSize(distinct); int[] elements = list.elements(); int[] tab = table; byte[] stat = state; int j=0; for (int i = tab.length ; i-- > 0 ;) { if (stat[i]==FULL) elements[j++]=tab[i]; } } /**
public boolean apply(int key) { list.add(key); return true; } }
public void doPostProcessing(CyNetwork net) { // Cleanup unnecessary references. edges.clear(); node_indices.clear(); edges = null; node_indices = null; allInteractions.clear(); allInteractions = null; } } // InteractionsReader
/** * Returns a deep copy of the receiver. * * @return a deep copy of the receiver. */ public Object clone() { // overridden for performance only. IntArrayList clone = new IntArrayList((int[]) elements.clone()); clone.setSizeRaw(size); return clone; } /**
/** * Not yet commented. */ public static void test(int weight, int size) { WeightedRandomSampler sampler = new WeightedRandomSampler(); sampler.setWeight(weight); cern.colt.list.IntArrayList sample = new cern.colt.list.IntArrayList(); for (int i=0; i<size; i++) { if (sampler.sampleNextElement()) sample.add(i); } System.out.println("Sample = "+sample); } /**
/** * 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 IntArrayList(int[] elements) { elements(elements); } /**