it.unimi.dsi.fastutil.objects.ObjectListIterator Java Examples
The following examples show how to use
it.unimi.dsi.fastutil.objects.ObjectListIterator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemItemCF.java From StreamingRec with Apache License 2.0 | 5 votes |
@Override protected void trainInternal(List<Item> items, List<ClickData> clickData) { //if we are supposed to only used the last N click and the number of training clicks is higher //we can just cut the data right here. if(buffer && clickData.size()>ringBuffer.size()){ //for batch training ringBuffer.clear(); clickData = clickData.subList(clickData.size()-bufferSize, clickData.size()); } //iterate over the click data and update the click maps of each item for (ClickData c : clickData) { //update the click maps of each item updateMap(c.click.userId, c.click.item.id); if(buffer){ //update the buffer so that these clicks are removed later from the click maps SimpleEntry<Long, Long> tuple = new AbstractMap.SimpleEntry<Long, Long>(c.click.userId, c.click.item.id); //if the click is already contained, remove it if(ringBuffer.contains(tuple)){ ringBuffer.remove(tuple); } //in any case, add the click at the end in the buffer ringBuffer.add(tuple); } } //if we are using only the most recent N clicks, remove "old" click from the map, here. if(buffer){ ObjectListIterator<Entry<Long,Long>> iterator = ringBuffer.iterator(); while(buffer && ringBuffer.size()>bufferSize){ Entry<Long, Long> next = iterator.next(); itemClickMap.get(next.getValue()).clear(userMap.get(next.getKey())); userItemMap.get(userMap.get(next.getKey())).remove(next.getValue()); iterator.remove(); } } }
Example #2
Source File: PermutedFrontCodedStringList.java From database with GNU General Public License v2.0 | 5 votes |
public ObjectListIterator<CharSequence> listIterator( final int k ) { return new AbstractObjectListIterator<CharSequence>() { final IntListIterator i = IntIterators.fromTo( 0, frontCodedStringList.size() ); public boolean hasNext() { return i.hasNext(); } public boolean hasPrevious() { return i.hasPrevious(); } public CharSequence next() { return frontCodedStringList.get( permutation[ i.nextInt() ] ); } public CharSequence previous() { return frontCodedStringList.get( permutation[ i.previousInt() ] ); } public int nextIndex() { return i.nextIndex(); } public int previousIndex() { return i.previousIndex(); } }; }
Example #3
Source File: FrontCodedStringList.java From database with GNU General Public License v2.0 | 5 votes |
public ObjectListIterator<MutableString> listIterator( final int k ) { return new AbstractObjectListIterator<MutableString>() { ObjectListIterator<?> i = utf8 ? byteFrontCodedList.listIterator( k ) : charFrontCodedList.listIterator( k ); public boolean hasNext() { return i.hasNext(); } public boolean hasPrevious() { return i.hasPrevious(); } public MutableString next() { return MutableString.wrap( utf8 ? byte2Char( (byte[])i.next(), null ) : (char[])i.next() ); } public MutableString previous() { return MutableString.wrap( utf8 ? byte2Char( (byte[])i.next(), null ) :(char[])i.previous() ); } public int nextIndex() { return i.nextIndex(); } public int previousIndex() { return i.previousIndex(); } }; }
Example #4
Source File: BlockContainer.java From WarpPI with Apache License 2.0 | 4 votes |
public boolean delBlock(final Caret caret) { boolean removed = false; int pos = 0; for (final Block b : content) { caret.skip(1); pos++; final int deltaCaret = caret.getRemaining(); final int caretOldPos = caret.getPosition(); removed = removed | b.delBlock(caret); if (caret.getRemaining() == 0 || removed == false && deltaCaret >= 0 && caret.getRemaining() < 0) { ObjectArrayList<Block> blocks = this.getBlockAt(pos - 1).get().getInnerBlocks(); ObjectArrayList<BlockContainer> innerContainers = this.getBlockAt(pos - 1).get().getInnerContainers(); int innerContainersBeforeCaret = 0; int currentBlockIndex = 0; if (innerContainers != null) { for (BlockContainer c : innerContainers) { currentBlockIndex += c.computeCaretMaxBound(); if (currentBlockIndex > deltaCaret) { break; } innerContainersBeforeCaret++; } } // If the caret is at the end of a block with inner containers don't delete anything and enter into that block. if (innerContainers == null || (innerContainers.size() - innerContainersBeforeCaret != 0)) { removeAt(pos - 1); if (blocks != null) { ObjectListIterator<Block> blocksIterator = blocks.iterator(); int blockNum = 0; while (blocksIterator.hasNext()) { Block block = blocksIterator.next(); addBlockUnsafe(pos - 1 + blockNum, block); blockNum++; } } caret.setPosition(caretOldPos - innerContainersBeforeCaret); removed = true; } } } caret.skip(1); if (removed) { recomputeDimensions(); } return removed; }
Example #5
Source File: CustomByteArrayFrontCodedList.java From database with GNU General Public License v2.0 | 4 votes |
public ObjectListIterator<byte[]> listIterator(final int start) { ensureIndex(start); return new AbstractObjectListIterator<byte[]>() { byte a[] = ByteArrays.EMPTY_ARRAY; int i = 0, pos = 0; boolean inSync; // Whether the current value in a is the string just // before the next to be produced. { if (start != 0) { if (start == n) i = start; // If we start at the end, we do nothing. else { pos = p[start / ratio]; int j = start % ratio; i = start - j; while (j-- != 0) next(); } } } public boolean hasNext() { return i < n; } public boolean hasPrevious() { return i > 0; } public int previousIndex() { return i - 1; } public int nextIndex() { return i; } public byte[] next() { int length, common; if (!hasNext()) throw new NoSuchElementException(); final BackingBuffer bb = CustomByteArrayFrontCodedList.this.bb; if (i % ratio == 0) { pos = p[i / ratio]; // length = readInt(array, pos); length = bb.readInt(pos); a = ByteArrays.ensureCapacity(a, length, 0); // System.arraycopy(array, pos + count(length), a, 0, length); bb.arraycopy(pos + count(length), a, 0, length); pos += length + count(length); inSync = true; } else { if (inSync) { // length = readInt(array, pos); // common = readInt(array, pos + count(length)); length = bb.readInt(pos); common = bb.readInt(pos + count(length)); a = ByteArrays.ensureCapacity(a, length + common, common); // System.arraycopy(array, pos + count(length) // + count(common), a, common, length); bb.arraycopy(pos + count(length) + count(common), a, common, length); pos += count(length) + count(common) + length; length += common; } else { a = ByteArrays.ensureCapacity(a, length = length(i), 0); extract(i, a, 0, length); } } i++; return ByteArrays.copy(a, 0, length); } public byte[] previous() { if (!hasPrevious()) throw new NoSuchElementException(); inSync = false; return getArray(--i); } }; }