HClust::IndexList
Inherits Reference < Object
An IndexList is an ordered collection of contiguous zero-based
indexes.
It supports efficient iteration and removal so it performs better than
an Array when there are frequent deletions.
Internally, it is implemented as a double-linked list such that
deleted indexes are marked as inactive, but otherwise kept in memory.
Therefore, indexing is not supported. Traversal is performed using the
#each methods.
The most typical use case of a IndexList is for representing a list
of nodes, where finding the closest pair is often desired. Hence,
convenience methods for finding the nearest index based on a given
distance metric are provided.
Constructors
Instance methods
Yields each index in the list within the given range. It discards skip elements before yielding.
Yields each index except index. Useful for iterating in pairs.
Returns true if the list includes the given index, else false.
Returns the nearest index to the given index based on the block's returns value. Both the index and distance taken from the distance matrix are yielded such that the block may compute a new distance if needed.
Returns the nearest index to the given index based on the block's returns value.
Returns the nearest index to the given index based on the distance matrix.
Returns the succeeding index to index, without doing any bounds
check.