Link a new node to the end of the linked for a hash index.

@param index an index into hashTable
@param lastLookup either -1 or the node to which the new node will be linked
@return the new node
357963
int linkNode(int index, int lastLookup) {

        // get the first reclaimed slot
        int lookup = reclaimedNodePointer;

        // A VoltDB extension to diagnose ArrayOutOfBounds.
        boolean voltDBreclaimed = (reclaimedNodePointer != -1);
        // Keep a history of events, wrapping to the start of the buffer when capacity runs out
        // so the most recent events are never lost.
        voltDBhistory[voltDBhistoryDepth++ % voltDBhistoryCapacity] = index;
        // End of VoltDB extension
        if (lookup == -1) {
            lookup = newNodePointer++;
        } else {

            // reset the first reclaimed slot
            reclaimedNodePointer = linkTable[lookup];
        }

        // link the node
        if (lastLookup == -1) {
            hashTable[index] = lookup;
        } else {
            linkTable[lastLookup] = lookup;
        }

        // A VoltDB extension to diagnose ArrayOutOfBounds.
        if (lookup >= linkTable.length) {
            StringBuilder report = new StringBuilder();
            report.append("linkTable size is ").append(linkTable.length);
            report.append(voltDBreclaimed ? " reclaimed" : " new").append(" index is ").append(lookup);
            report.append(" linkTable content is [");
            for (int link : linkTable) {
                report.append(link).append(", ");
            }
            report.append("]\n");
            report.append(" hashTable content is [");
            for (int look : hashTable) {
                report.append(look).append(", ");
            }
            report.append("]\n");
            report.append(" history is [");
            int depth = 0;
            for (int look : voltDBhistory) {
                ++depth;
                if (depth == (voltDBhistoryDepth % voltDBhistoryCapacity)) {
                    report.append(" /* <- history ends here and/or starts here -> */ ");
                }
                if (look < 0) {
                    report.append(-(look+1)).append(" unlnkd, ");
                } else if (look > 1000000) {
                    report.append(look-1000000).append(" rmdlkp, ");
                } else {
                    report.append(look).append(" linked, ");
                }
            }
            report.append("]\n");
            report.append(" lost history length is ").append(voltDBhistoryDepth / voltDBhistoryCapacity * voltDBhistoryCapacity);
            report.append("next reclaimedPointer is ").append(reclaimedNodePointer);
            report.append(" next newNodePointer is ").append(newNodePointer);
            report.append(" last reset was #").append(voltDBresetCount).append(" after event ").append(voltDBlastResetEvent);
            report.append(" from ").append(voltDBresetCapacity);
            report.append(" last clear was #").append(voltDBclearCount).append(" after event ").append(voltDBlastClearEvent);
            report.append(" from ").append(voltDBclearCapacity);
            throw new ArrayIndexOutOfBoundsException(report.toString());
        }
        // End of VoltDB extension
        linkTable[lookup] = -1;

        elementCount++;

        modified = true;

        return lookup;
    }
1051824
@Override
  public ORecordIteratorClusters<REC> last() {
    currentClusterIdx = clusterIds.length - 1;
    current.clusterPosition = liveUpdated ? database.countClusterElements(clusterIds[currentClusterIdx]) : lastClusterPosition + 1;
    return this;
  }
466882
private int insertTailoredNodeAfter(int index, int strength) {
        assert(0 <= index && index < nodes.size());
        if(strength >= Collator.SECONDARY) {
            index = findCommonNode(index, Collator.SECONDARY);
            if(strength >= Collator.TERTIARY) {
                index = findCommonNode(index, Collator.TERTIARY);
            }
        }
        // Postpone insertion:
        // Insert the new node before the next one with a strength at least as strong.
        long node = nodes.elementAti(index);
        int nextIndex;
        while((nextIndex = nextIndexFromNode(node)) != 0) {
            node = nodes.elementAti(nextIndex);
            if(strengthFromNode(node) <= strength) { break; }
            // Skip the next node which has a weaker (larger) strength than the new one.
            index = nextIndex;
        }
        node = IS_TAILORED | nodeFromStrength(strength);
        return insertNodeBetween(index, nextIndex, node);
    }
249234
protected int nextLookup(int lookup) {

        for (++lookup; lookup < hashIndex.newNodePointer; lookup++) {
            if (isObjectKey) {
                if (objectKeyTable[lookup] != null) {
                    return lookup;
                }
            } else if (isIntKey) {
                if (intKeyTable[lookup] != 0) {
                    return lookup;
                } else if (hasZeroKey && lookup == zeroKeyIndex) {
                    return lookup;
                }
            } else {
                if (longKeyTable[lookup] != 0) {
                    return lookup;
                } else if (hasZeroKey && lookup == zeroKeyIndex) {
                    return lookup;
                }
            }
        }

        return -1;
    }
428952
private GeometryIndex recursiveCreate(GeometryIndex index, int lastValue, GeometryIndexType lastType) {
		if (index.hasChild()) {
			return new GeometryIndex(index.getType(), index.getValue(), recursiveCreate(index.getChild(), lastValue,
					lastType));
		} else {
			GeometryIndexType type = lastType == null ? index.getType() : lastType;
			return new GeometryIndex(type, lastValue, null);
		}
	}
356465
public void setLastApplied(long index) {
    // Query callbacks for this session are added to the indexQueries map to be executed once the required index
    // for the query is reached. For each increment of the index, trigger query callbacks that are dependent
    // on the specific index.
    for (long i = lastApplied + 1; i <= index; i++) {
      lastApplied = i;
      List<Runnable> queries = this.indexQueries.remove(lastApplied);
      if (queries != null) {
        for (Runnable query : queries) {
          query.run();
        }
      }
    }
  }
1309618
private static Node getNthSibling(Node first, int index) {
    Node sibling = first;
    while (index != 0 && sibling != null) {
      sibling = sibling.getNext();
      index--;
    }
    return sibling;
  }
1245401
public static void replaceLast(StringBuffer haystack, String needle, String newNeedle) {
		int idx = haystack.lastIndexOf(needle);
		if (idx != -1) {
			haystack.replace(idx, idx + needle.length(), newNeedle);
		}
	}
282795
public ObjectSinkNode removeLast() {
        if ( this.lastNode == null ) {
            return null;
        }
        final ObjectSinkNode node = this.lastNode;
        this.lastNode = node.getPreviousObjectSinkNode();
        node.setPreviousObjectSinkNode( null );
        if ( this.lastNode != null ) {
            this.lastNode.setNextObjectSinkNode( null );
        } else {
            this.firstNode = this.lastNode;
        }
        this.size--;
        return node;
    }
966213
def move_to_end(self, key, last=True):
        '''

        '''
        link = self.__map[key]
        link_prev = link.prev
        link_next = link.next
        link_prev.next = link_next
        link_next.prev = link_prev
        root = self.__root
        if last:
            last = root.prev
            link.prev = last
            link.next = root
            last.next = root.prev = link
        else:
            first = root.next
            link.prev = root
            link.next = first
            root.next = first.prev = link
719707
final Node<K,V> getNode(int hash, Object key) {
        Node<K,V>[] tab; Node<K,V> first, e; int n; K k;
        if ((tab = table) != null && (n = tab.length) > 0 &&
            (first = tab[(n - 1) & hash]) != null) {
            if (first.hash == hash && // always check first node
                ((k = first.key) == key || (key != null && key.equals(k))))
                return first;
            if ((e = first.next) != null) {
                if (first instanceof TreeNode)
                    return ((TreeNode<K,V>)first).getTreeNode(hash, key);
                do {
                    if (e.hash == hash &&
                        ((k = e.key) == key || (key != null && key.equals(k))))
                        return e;
                } while ((e = e.next) != null);
            }
        }
        return null;
    }
727241
private Node<K, V> link(Node<K, V> y, Node<K, V> x) {
        y.parent = x;
        Node<K, V> child = x.child;
        if (child == null) {
            x.child = y;
            y.next = y;
            y.prev = y;
        } else {
            y.prev = child;
            y.next = child.next;
            child.next = y;
            y.next.prev = y;
        }
        return x;
    }
826099
public KdTree.Node requestNode(P point , int index ) {
		KdTree.Node n = requestNode();
		n.point = point;
		n.index = index;
		n.split = -1;
		return n;
	}
1208047
private LinkedHashMap<HypergraphNode<Variable>, Integer> orderingFromTentativeNewLocations(final LinkedHashMap<HypergraphNode<Variable>, Double> newLocations) {
    final LinkedHashMap<HypergraphNode<Variable>, Integer> ordering = new LinkedHashMap<>();
    final List<Map.Entry<HypergraphNode<Variable>, Double>> list = new ArrayList<>(newLocations.entrySet());
    Collections.sort(list, COMPARATOR);
    int count = 0;
    for (final Map.Entry<HypergraphNode<Variable>, Double> entry : list)
      ordering.put(entry.getKey(), count++);
    return ordering;
  }

  /**
   * The abortion criteria for the FORCE algorithm.
   * @param lastOrdering    the ordering of the last step
   * @param currentOrdering the ordering of the current step
   * @return {@code true} if the algorithm should proceed, {@code false} if it should stop
   */
  private boolean shouldProceed(final Map<HypergraphNode<Variable>, Integer> lastOrdering, final Map<HypergraphNode<Variable>, Integer> currentOrdering) {
    return !lastOrdering.equals(currentOrdering);
  }
209968
private static int lastIndexOf(Object o, Object[] elements, int index) {
        if (o == null) {
            for (int i = index; i >= 0; i--)
                if (elements[i] == null)
                    return i;
        } else {
            for (int i = index; i >= 0; i--)
                if (o.equals(elements[i]))
                    return i;
        }
        return -1;
    }
435018
public IndexNode visitLastIndex(Consumer<? super IndexNode> visitor) {
    getChildren().forEach(n -> n.visitLastIndex(visitor));
    visitor.accept(this);
    return refresh();
  }
130243
public JSONNavi<?> at(int index) {
		if (failure)
			return this;
		if (!(current instanceof List))
			return failure("current node is not an Array", index);
		@SuppressWarnings("unchecked")
		List<Object> lst = ((List<Object>) current);
		if (index < 0) {
			index = lst.size() + index;
			if (index < 0)
				index = 0;
		}
		if (index >= lst.size())
			if (readonly)
				return failure("Out of bound exception for index", index);
			else {
				stack.add(current);
				path.add(index);
				current = null;
				missingKey = index;
				return this;
			}
		Object next = lst.get(index);
		stack.add(current);
		path.add(index);
		current = next;
		return this;
	}