Iterator pointing to the beginning element.
const begin = container.begin();
const end = container.end();
for (const it = begin; !it.equals(end); it.next()) {
doSomething(it.pointer);
}
Iterator pointing to the super end like c++.
const begin = container.begin();
const end = container.end();
for (const it = begin; !it.equals(end); it.next()) {
doSomething(it.pointer);
}
Iterator pointing to the end element.
const rBegin = container.rBegin();
const rEnd = container.rEnd();
for (const it = rBegin; !it.equals(rEnd); it.next()) {
doSomething(it.pointer);
}
Iterator pointing to the super begin like c++.
const rBegin = container.rBegin();
const rEnd = container.rEnd();
for (const it = rBegin; !it.equals(rEnd); it.next()) {
doSomething(it.pointer);
}
Removes element by iterator and move iter
to next.
The next iterator.
container.eraseElementByIterator(container.begin());
container.eraseElementByIterator(container.end()); // throw a RangeError
The iterator you want to erase.
Insert several elements after the specified position.
The size of container after inserting.
const container = new Vector([1, 2, 3]);
container.insert(1, 4); // [1, 4, 2, 3]
container.insert(1, 5, 3); // [1, 5, 5, 5, 4, 2, 3]
The position you want to insert.
The element you want to insert.
The number of elements you want to insert (default 1).
An iterator pointing to the element if found, or super end if not found.
container.find(1).equals(container.end());
The element you want to find.
Sort the container.
The container's self.
const container = new Vector([3, 1, 10]);
container.sort(); // [1, 10, 3]
container.sort((x, y) => x - y); // [1, 3, 10]
Optional
cmp: ((x: T, y: T) => number)Comparison function to sort.
Merges two sorted lists.
The size of list after merging.
const linkA = new LinkList([1, 3, 5]);
const linkB = new LinkList([2, 4, 6]);
linkA.merge(linkB); // [1, 2, 3, 4, 5];
The other list you want to merge (must be sorted).
Iterate over all elements in the container.
container.forEach((element, index) => console.log(element, index));
Generated using TypeDoc
Returns
The size of the container.
Example