/** * Returns a list which is a concatenation of <code>times</code> times the receiver. * * @param times the number of times the receiver shall be copied. */ public AbstractLongList times(int times) { AbstractLongList newList = new LongArrayList(times * size()); for (int i = times; --i >= 0; ) { newList.addAllOfFromTo(this, 0, size() - 1); } return newList; }
@Override public AbstractLongList getRawNeighborhood(AtomicQuery query, InternalTitanTransaction tx) { Preconditions.checkArgument( QueryUtil.queryCoveredByDiskIndexes(query), "Raw retrieval is currently does not support in-memory filtering"); List<Entry> entries = queryForEntries(query, tx.getTxHandle()); InternalTitanVertex node = query.getNode(); TitanType titanType = null; if (query.hasEdgeTypeCondition()) titanType = query.getTypeCondition(); AbstractLongList result = new LongArrayList(); for (Entry entry : entries) { if (!query.hasEdgeTypeCondition()) { long etid = IDHandler.readEdgeType(entry.getColumn(), idManager); if (titanType == null || titanType.getID() != etid) { titanType = getTypeFromID(etid, tx); } } if (titanType.isPropertyKey() || (!titanType.isModifiable() && !query.queryUnmodifiable())) { continue; // Skip since it does not match query } // Get neighboring node id long iddiff = VariableLong.read(entry.getValue()); long nghid = iddiff + node.getID(); result.add(nghid); if (result.size() >= query.getLimit()) break; } return result; }
/** * Removes from the receiver all elements that are contained in the specified list. Tests for * identity. * * @param other the other list. * @return <code>true</code> if the receiver changed as a result of the call. */ public boolean removeAll(AbstractLongList other) { if (other.size() == 0) return false; // nothing to do int limit = other.size() - 1; int j = 0; for (int i = 0; i < size; i++) { if (other.indexOfFromTo(getQuick(i), 0, limit) < 0) setQuick(j++, getQuick(i)); } boolean modified = (j != size); 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 if (!(otherObj instanceof AbstractLongList)) { return false; } if (this == otherObj) return true; if (otherObj == null) return false; AbstractLongList other = (AbstractLongList) otherObj; if (size() != other.size()) return false; for (int i = size(); --i >= 0; ) { if (getQuick(i) != other.getQuick(i)) return false; } return true; }
/** * 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) { int length = to - from + 1; if (length > 0) { checkRangeFromTo(from, to, size()); checkRangeFromTo(otherFrom, otherFrom + length - 1, other.size()); // unambiguous copy (it may hold other==this) if (from <= otherFrom) { for (; --length >= 0; ) setQuick(from++, other.getQuick(otherFrom++)); } else { int otherTo = otherFrom + length - 1; for (; --length >= 0; ) setQuick(to--, other.getQuick(otherTo--)); } } }
/** * Retains (keeps) only the elements in the receiver that are contained in the specified other * list. In other words, removes from the receiver all of its elements that are not contained in * the specified other list. * * @param other the other list to test against. * @return <code>true</code> if the receiver changed as a result of the call. */ public boolean retainAll(AbstractLongList other) { if (other.size() == 0) { if (size == 0) return false; setSize(0); return true; } int limit = other.size() - 1; int j = 0; for (int i = 0; i < size; i++) { if (other.indexOfFromTo(getQuick(i), 0, limit) >= 0) setQuick(j++, getQuick(i)); } boolean modified = (j != size); setSize(j); return modified; }