private void startNewPage() { if (currentPageBuilder != null) { completedPagesMemorySize += currentPageBuilder.getRetainedSizeInBytes(); currentPageBuilder = currentPageBuilder.newPageBuilderLike(); } else { currentPageBuilder = new PageBuilder(types); } for (int i = 0; i < types.size(); i++) { channelBuilders.get(i).add(currentPageBuilder.getBlockBuilder(i)); } }
public void addPage(Page page) { // ignore empty pages if (page.getPositionCount() == 0) { return; } positionCount += page.getPositionCount(); int pageIndex = (channels.length > 0) ? channels[0].size() : 0; for (int i = 0; i < channels.length; i++) { Block block = page.getBlock(i); if (eagerCompact) { block = block.copyRegion(0, block.getPositionCount()); } channels[i].add(block); pagesMemorySize += block.getRetainedSizeInBytes(); } for (int position = 0; position < page.getPositionCount(); position++) { long sliceAddress = encodeSyntheticAddress(pageIndex, position); valueAddresses.add(sliceAddress); } estimatedSize = calculateEstimatedSize(); }
/** * Puts the element into the priority queue. * <ul> * <li> If key does not exist, it is added to the priority queue. </li> * <li> If key exists, then the value is updated, and the priority queue ordering is maintained. </li> * <li> Runtime complexity of {@code O(log(n)}). </li> * </ul> * @param key Integer key for the value * @param value Value of the key */ @SuppressWarnings("unchecked") public void put(int key, T value) { if (!_keyToIndexMap.containsKey(key)) { _values.add(value); int last = _values.size() - 1; updateKeyIndexMap(key, last); siftUp(last); } else { int index = _keyToIndexMap.get(key); _values.set(index, value); // Sift the value up or down, as the case may be. if (!siftDown(index)) { siftUp(index); } } }
/** Adds a new callback to this builder. * * @param callback a callback. */ public void add( final Callback callback ) { callbacks.add( callback ); }
@Override public void add(K k) { ObjectArrayList.this.add(pos++, k); last = -1; } @Override
/** Adds a new callback to this builder. * * @param callback a callback. */ public void add(final Callback callback) { callbacks.add(callback); }
/** Adds a new callback to this builder. * * @param callback a callback. */ public void add( final Callback callback ) { callbacks.add( callback ); }
/** Adds a new callback to this builder at a specified position. * * @param position a position in the current callback list. * @param callback a callback. */ public void add(final int position, final Callback callback) { callbacks.add(position, callback); }
@Override public Collection<Integer> getIncidentVertices(final Long e) { final int x = (int)(e.longValue() >>> 32); final int y = e.intValue(); if (x == y) return ObjectLists.singleton(Integer.valueOf(x)); final ObjectArrayList<Integer> res = new ObjectArrayList<>(); res.add(Integer.valueOf(x)); res.add(Integer.valueOf(y)); return res; }
private void readObject( final ObjectInputStream s ) throws IOException, ClassNotFoundException { s.defaultReadObject(); final int size = s.readInt(); final ObjectArrayList<TRECDocumentDescriptor> descriptors = new ObjectArrayList<TRECDocumentDescriptor>(); descriptors.ensureCapacity( size ); for ( int i = 0; i < size; i++ ) descriptors.add( new TRECDocumentDescriptor( s.readInt(), s.readLong(), s.readInt(), s.readInt() ) ); this.descriptors = descriptors; }
/** Returns all lines of the file wrapped by this file-lines collection. * * @return all lines of the file wrapped by this file-lines collection. */ public ObjectList<MutableString> allLines() { final ObjectArrayList<MutableString> result = new ObjectArrayList<MutableString>(); for( Iterator<MutableString> i = iterator(); i.hasNext(); ) result.add( i.next().copy() ); return result; }
/** Returns all lines of the file wrapped by this file-lines collection. * * @return all lines of the file wrapped by this file-lines collection. */ public ObjectList<MutableString> allLines() { final ObjectArrayList<MutableString> result = new ObjectArrayList<>(); for(final Iterator<MutableString> i = iterator(); i.hasNext();) result.add(i.next().copy()); return result; }
private void startNewPage() { if (currentPageBuilder != null) { completedPagesMemorySize += currentPageBuilder.getRetainedSizeInBytes(); } currentPageBuilder = new PageBuilder(types); for (int i = 0; i < types.size(); i++) { channelBuilders.get(i).add(currentPageBuilder.getBlockBuilder(i)); } }
@Override public boolean add(final T element) { if (this.usedElements == super.size()) // append super.add(element); else super.set(this.usedElements, element); this.usedElements++; return true; }
private int getResults( final DocumentIterator documentIterator, final int offset, final int length, final ObjectArrayList<DocumentScoreInfo<Reference2ObjectMap<Index,SelectedInterval[]>>> results, final IntSet alreadySeen ) throws IOException { int document, count = 0; // Number of not-already-seen documents // Unfortunately, to provide the exact count of results we have to scan the whole iterator. while ( ( document = documentIterator.nextDocument() ) != -1 ) { if ( alreadySeen != null && ! alreadySeen.add( document ) ) continue; if ( count >= offset && count < offset + length ) results.add( new DocumentScoreInfo<Reference2ObjectMap<Index,SelectedInterval[]>>( document, -1 ) ); count++; } return count; }
public Interval nextInterval() throws IOException { if ( pos < cachedIntervals.size() ) return cachedIntervals.get( pos++ ); else { final Interval next = intervalIterator.nextInterval(); if ( next == null ) return null; cachedIntervals.add( next ); pos++; return next; } }
/** Returns all lines remaining in this iterator as a list. * * @return all lines remaining in this iterator as a list. */ public List<MutableString> allLines() { final ObjectArrayList<MutableString> result = new ObjectArrayList<MutableString>(); while( hasNext() ) result.add( next().copy() ); return result; } }
/** Returns all lines remaining in this iterator as a list. * * @return all lines remaining in this iterator as a list. */ public List<MutableString> allLines() { final ObjectArrayList<MutableString> result = new ObjectArrayList<>(); while(hasNext()) result.add(next().copy()); return result; } }
@Override protected Class<?>[] getSignatureTypes(final Method method) { Class<?>[] signatureTypes = super.getSignatureTypes(method); if (this.needsInstance(method)) { final ObjectArrayList<Class<?>> paramList = ObjectArrayList.wrap(signatureTypes); paramList.ensureCapacity(paramList.size() + 1); paramList.add(0, method.getDeclaringClass()); signatureTypes = paramList.elements(); } return signatureTypes; }
private int addBlock(ObjectArrayList<AlignmentBlock> blocks, int start, ByteArrayList bases, ByteArrayList scores) { blocks.add( new AlignmentBlockImpl(start, bases.toByteArray(new byte[bases.size()]), scores.toByteArray(new byte[scores.size()]))); start += bases.size(); bases.clear(); scores.clear(); return start; }