From 44e251d9b76d9c52273c037ce585ca2ccc8a15db Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Sat, 24 Sep 2016 01:15:22 +0900 Subject: [PATCH] TypeScript-STL v1.1 --- typescript-stl/typescript-stl.d.ts | 13260 ++++++++++++++------------- 1 file changed, 6715 insertions(+), 6545 deletions(-) diff --git a/typescript-stl/typescript-stl.d.ts b/typescript-stl/typescript-stl.d.ts index 36ad79e4a1..06edc79bec 100644 --- a/typescript-stl/typescript-stl.d.ts +++ b/typescript-stl/typescript-stl.d.ts @@ -1,11 +1,11 @@ -// Type definitions for TypeScript-STL v1.0.8 +// Type definitions for TypeScript-STL v1.1.0 // Project: https://github.com/samchon/typescript-stl // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "typescript-stl" { - export = std; + export = std; } /** @@ -129,10 +129,21 @@ declare namespace std { * first but not the element pointed by last. * @param fn Unary function that accepts an element in the range as argument. This can either be a function p * ointer or a move constructible function object. Its return value, if any, is ignored. - * - * @return Returns fn. */ function for_each, Func extends (val: T) => any>(first: InputIterator, last: InputIterator, fn: Func): Func; + /** + * Apply function to range. + * + * Applies function *fn* to each of the elements in the range [*first*, *first + n*). + * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param n the number of elements to apply the function to + * @param fn Unary function that accepts an element in the range as argument. This can either be a function p + * ointer or a move constructible function object. Its return value, if any, is ignored. + * + * @return first + n + */ + function for_each_n>(first: InputIterator, n: number, fn: (val: T) => any): InputIterator; /** *

Test condition on all elements in range.

* @@ -210,7 +221,7 @@ declare namespace std { * @return true if all the elements in the range [first1, last1) compare equal to those * of the range starting at first2, and false otherwise. */ - function equal>(first1: Iterator1, last1: Iterator1, first2: Iterator): boolean; + function equal>(first1: InputIterator, last1: InputIterator, first2: Iterator): boolean; /** *

Test whether the elements in two ranges are equal.

* @@ -230,7 +241,7 @@ declare namespace std { * @return true if all the elements in the range [first1, last1) compare equal to those * of the range starting at first2, and false otherwise. */ - function equal>(first1: Iterator1, last1: Iterator1, first2: Iterator, pred: (x: T, y: T) => boolean): boolean; + function equal>(first1: InputIterator, last1: InputIterator, first2: Iterator, pred: (x: T, y: T) => boolean): boolean; /** *

Test whether range is permutation of another.

* @@ -2740,6 +2751,46 @@ declare namespace std { */ function minmax_element>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): Pair; } +declare namespace std.base { + /** + *

Static class holding enumeration codes of color of Red-black tree.

+ * + *

Color codes imposed to nodes of RB-Tree are following those rules:

+ * + *
    + *
  1. A node is either red or black.
  2. + *
  3. The root is black. This rule is sometimes omitted. Since the root can + * always be changed from red to black, but not + * necessarily vice versa, this rule has little effect on analysis.
  4. + *
  5. All leaves (NIL; null) are black.
  6. + *
  7. If a node is red, then both its children are + * black.
  8. + *
  9. Every path from a given node to any of its descendant NIL nodes contains the same number of + * black nodes. Some definitions: the number of + * black nodes from the root to a node is the node's + * black depth; the uniform number of black + * nodes in all paths from root to the leaves is called the black-height of + * the red-black tree.
  10. + *
+ * + * @author Migrated by Jeongho Nam + */ + enum Color { + /** + *

Code of color black.

+ * + *
    + *
  • Those are clearly black: root, leaf nodes or children nodes of red.
  • + *
  • Every path from a given nodes containes the same number of black nodes exclude NIL(s).
  • + *
+ */ + BLACK = 0, + /** + *

Code of color red.

+ */ + RED = 1, + } +} declare namespace std.base { /** *

An abstract container.

@@ -2852,4856 +2903,6 @@ declare namespace std.base { swap(obj: IContainer): void; } } -declare namespace std { - /** - *

Bi-directional iterator.

- * - *

{@link Iterator Bidirectional iterators} are iterators that can be used to access the sequence of elements - * in a range in both directions (towards the end and towards the beginning).

- * - *

All {@link IArrayIterator random-access iterators} are also valid {@link Iterrator bidirectional iterators}. - *

- * - *

There is not a single type of {@link Iterator bidirectional iterator}: {@link IContainer Each container} - * may define its own specific iterator type able to iterate through it and access its elements.

- * - *

- * - *

- * - * @reference http://www.cplusplus.com/reference/iterator/BidirectionalIterator - * @author Jeongho Nam - */ - abstract class Iterator { - /** - * Source container of the iterator is directing for. - */ - protected source_: base.IContainer; - /** - * Construct from the source {@link IContainer container}. - * - * @param source The source - */ - constructor(source: base.IContainer); - /** - *

Get iterator to previous element.

- *

If current iterator is the first item(equal with {@link IContainer.begin IContainer.begin()}), - * returns {@link IContainer.end IContainer.end()}.

- * - * @return An iterator of the previous item. - */ - abstract prev(): Iterator; - /** - *

Get iterator to next element.

- *

If current iterator is the last item, returns {@link IContainer.end IContainer.end()}.

- * - * @return An iterator of the next item. - */ - abstract next(): Iterator; - /** - * Advances the {@link Iterator} by n element positions. - * - * @param n Number of element positions to advance. - * @return An advanced iterator. - */ - advance(n: number): Iterator; - /** - * Get source - */ - get_source(): base.IContainer; - /** - *

Whether an iterator is equal with the iterator.

- * - *

Compare two iterators and returns whether they are equal or not.

- * - *

Note

- *

Iterator's equal_to() only compare souce container and index number.

- * - *

Although elements in a pair, key and value are equal_to, if the source map or - * index number is different, then the {@link equal_to equal_to()} will return false. If you want to - * compare the elements of a pair, compare them directly by yourself.

- * - * @param obj An iterator to compare - * @return Indicates whether equal or not. - */ - equal_to(obj: Iterator): boolean; - /** - *

Get value of the iterator is pointing.

- * - * @return A value of the iterator. - */ - value: T; - abstract swap(obj: Iterator): void; - } -} -declare namespace std { - /** - *

This class reverses the direction in which a bidirectional or random-access iterator iterates through a range. - *

- * - *

A copy of the original iterator (the {@link Iterator base iterator}) is kept internally and used to reflect - * the operations performed on the {@link ReverseIterator}: whenever the {@link ReverseIterator} is incremented, its - * {@link Iterator base iterator} is decreased, and vice versa. A copy of the {@link Iterator base iterator} with the - * current state can be obtained at any time by calling member {@link base}.

- * - *

Notice however that when an iterator is reversed, the reversed version does not point to the same element in - * the range, but to the one preceding it. This is so, in order to arrange for the past-the-end element of a - * range: An iterator pointing to a past-the-end element in a range, when reversed, is pointing to the last element - * (not past it) of the range (this would be the first element of the reversed range). And if an iterator to the - * first element in a range is reversed, the reversed iterator points to the element before the first element (this - * would be the past-the-end element of the reversed range).

- * - *

- * - *

- * - * @reference http://www.cplusplus.com/reference/iterator/reverse_iterator - * @author Jeongho Nam - */ - abstract class ReverseIterator, This extends ReverseIterator> extends Iterator { - /** - * @hidden - */ - protected base_: Base; - /** - * Construct from base iterator. - * - * @param base A reference of the base iterator, which iterates in the opposite direction. - */ - constructor(base: Base); - /** - *

Return base iterator.

- * - *

Return a reference of the base iteraotr.

- * - *

The base iterator is an iterator of the same type as the one used to construct the {@link ReverseIterator}, - * but pointing to the element next to the one the {@link ReverseIterator} is currently pointing to - * (a {@link ReverseIterator} has always an offset of -1 with respect to its base iterator). - * - * @return A reference of the base iterator, which iterates in the opposite direction. - */ - base(): Base; - /** - * @hidden - */ - protected abstract create_neighbor(base: Base): This; - /** - *

Get value of the iterator is pointing.

- * - * @return A value of the reverse iterator. - */ - value: T; - /** - * @inheritdoc - */ - prev(): This; - /** - * @inheritdoc - */ - next(): This; - /** - * @inheritdoc - */ - advance(n: number): This; - /** - * @inheritdoc - */ - equal_to(obj: This): boolean; - /** - * @inheritdoc - */ - swap(obj: This): void; - } - /** - *

Return distance between {@link Iterator iterators}.

- * - *

Calculates the number of elements between first and last.

- * - *

If it is a {@link IArrayIterator random-access iterator}, the function uses operator- to calculate this. - * Otherwise, the function uses the increase operator {@link Iterator.next next()} repeatedly.

- * - * @param first Iterator pointing to the initial element. - * @param last Iterator pointing to the final element. This must be reachable from first. - * - * @return The number of elements between first and last. - */ - function distance>(first: InputIterator, last: InputIterator): number; - /** - *

Advance iterator.

- * - *

Advances the iterator it by n elements positions.

- * - * @param it Iterator to be advanced. - * @param n Number of element positions to advance. - * - * @return An iterator to the element n positions before it. - */ - function advance>(it: InputIterator, n: number): InputIterator; - /** - *

Get iterator to previous element.

- * - *

Returns an iterator pointing to the element that it would be pointing to if advanced -n positions.

- * - * @param it Iterator to base position. - * @param n Number of element positions offset (1 by default). - * - * @return An iterator to the element n positions before it. - */ - function prev>(it: BidirectionalIterator, n?: number): BidirectionalIterator; - /** - *

Get iterator to next element.

- * - *

Returns an iterator pointing to the element that it would be pointing to if advanced n positions.

- * - * @param it Iterator to base position. - * @param n Number of element positions offset (1 by default). - * - * @return An iterator to the element n positions away from it. - */ - function next>(it: ForwardIterator, n?: number): ForwardIterator; - /** - *

Iterator to beginning.

- * - *

Returns an iterator pointing to the first element in the sequence.

- * - *

If the sequence is empty, the returned value shall not be dereferenced.

- * - * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. - * - * @return The same as returned by {@link IContainer.begin container.begin()}. - */ - function begin(container: Vector): VectorIterator; - /** - *

Iterator to beginning.

- * - *

Returns an iterator pointing to the first element in the sequence.

- * - *

If the sequence is empty, the returned value shall not be dereferenced.

- * - * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. - * - * @return The same as returned by {@link IContainer.begin container.begin()}. - */ - function begin(container: List): ListIterator; - /** - *

Iterator to beginning.

- * - *

Returns an iterator pointing to the first element in the sequence.

- * - *

If the sequence is empty, the returned value shall not be dereferenced.

- * - * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. - * - * @return The same as returned by {@link IContainer.begin container.begin()}. - */ - function begin(container: Deque): DequeIterator; - /** - *

Iterator to beginning.

- * - *

Returns an iterator pointing to the first element in the sequence.

- * - *

If the sequence is empty, the returned value shall not be dereferenced.

- * - * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. - * - * @return The same as returned by {@link IContainer.begin container.begin()}. - */ - function begin(container: base.SetContainer): SetIterator; - /** - *

Iterator to beginning.

- * - *

Returns an iterator pointing to the first element in the sequence.

- * - *

If the sequence is empty, the returned value shall not be dereferenced.

- * - * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. - * - * @return The same as returned by {@link IContainer.begin container.begin()}. - */ - function begin(container: base.MapContainer): MapIterator; - /** - *

Iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the sequence.

- * - *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

- * - * @param container A container of a class type for which member {@link IContainer.end end} is defined. - * - * @return The same as returned by {@link IContainer.end container.end()}. - */ - function end(container: Vector): VectorIterator; - /** - *

Iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the sequence.

- * - *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

- * - * @param container A container of a class type for which member {@link IContainer.end end} is defined. - * - * @return The same as returned by {@link IContainer.end container.end()}. - */ - function end(container: List): ListIterator; - /** - *

Iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the sequence.

- * - *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

- * - * @param container A container of a class type for which member {@link IContainer.end end} is defined. - * - * @return The same as returned by {@link IContainer.end container.end()}. - */ - function end(container: Deque): DequeIterator; - /** - *

Iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the sequence.

- * - *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

- * - * @param container A container of a class type for which member {@link IContainer.end end} is defined. - * - * @return The same as returned by {@link IContainer.end container.end()}. - */ - function end(container: base.SetContainer): SetIterator; - /** - *

Iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the sequence.

- * - *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

- * - * @param container A container of a class type for which member {@link IContainer.end end} is defined. - * - * @return The same as returned by {@link IContainer.end container.end()}. - */ - function end(container: base.MapContainer): MapIterator; -} -declare namespace std.Deque { - type iterator = std.DequeIterator; - type reverse_iterator = std.DequeReverseIterator; -} -declare namespace std { - /** - *

Double ended queue.

- * - *

{@link Deque} (usually pronounced like "deck") is an irregular acronym of - * double-ended queue. Double-ended queues are sequence containers with dynamic sizes that can be - * expanded or contracted on both ends (either its front or its back).

- * - *

Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any - * case, they allow for the individual elements to be accessed directly through random access iterators, with storage - * handled automatically by expanding and contracting the container as needed.

- * - *

Therefore, they provide a functionality similar to vectors, but with efficient insertion and deletion of - * elements also at the beginning of the sequence, and not only at its end. But, unlike {@link Vector Vectors}, - * {@link Deque Deques} are not guaranteed to store all its elements in contiguous storage locations: accessing - * elements in a deque by offsetting a pointer to another element causes undefined behavior.

- * - *

Both {@link Vector}s and {@link Deque}s provide a very similar interface and can be used for similar purposes, - * but internally both work in quite different ways: While {@link Vector}s use a single array that needs to be - * occasionally reallocated for growth, the elements of a {@link Deque} can be scattered in different chunks of - * storage, with the container keeping the necessary information internally to provide direct access to any of its - * elements in constant time and with a uniform sequential interface (through iterators). Therefore, - * {@link Deque Deques} are a little more complex internally than {@link Vector}s, but this allows them to grow more - * efficiently under certain circumstances, especially with very long sequences, where reallocations become more - * expensive.

- * - *

For operations that involve frequent insertion or removals of elements at positions other than the beginning or - * the end, {@link Deque Deques} perform worse and have less consistent iterators and references than - * {@link List Lists}.

- * - *

- * - *

- * - *

Container properties

- *
- *
Sequence
- *
Elements in sequence containers are ordered in a strict linear sequence. Individual elements - * are accessed by their position in this sequence.
- * - *
Dynamic array
- *
Generally implemented as a dynamic array, it allows direct access to any element in the - * sequence and provides relatively fast addition/removal of elements at the beginning or the end - * of the sequence.
- *
- * - * @param Type of the elements. - * - * @reference http://www.cplusplus.com/reference/deque/deque/ - * @author Jeongho Nam - */ - class Deque extends base.Container implements base.IArrayContainer, base.IDequeContainer { - /** - * @hidden - */ - private static ROW; - /** - * @hidden - */ - private static MIN_CAPACITY; - /** - * @hidden - */ - private matrix_; - /** - * @hidden - */ - private size_; - /** - * @hidden - */ - private capacity_; - /** - * @hidden - */ - private get_col_size(); - /** - *

Default Constructor.

- * - *

Constructs an empty container, with no elements.

- */ - constructor(); - /** - *

Initializer list Constructor.

- * - *

Constructs a container with a copy of each of the elements in array, in the same order.

- * - * @param array An array containing elements to be copied and contained. - */ - constructor(items: Array); - /** - *

Fill Constructor.

- * - *

Constructs a container with n elements. Each element is a copy of val (if provided).

- * - * @param n Initial container size (i.e., the number of elements in the container at construction). - * @param val Value to fill the container with. Each of the n elements in the container is - * initialized to a copy of this value. - */ - constructor(size: number, val: T); - /** - *

Copy Constructor.

- * - *

Constructs a container with a copy of each of the elements in container, in the same order.

- * - * @param container Another container object of the same type (with the same class template - * arguments T), whose contents are either copied or acquired. - */ - constructor(container: Deque); - /** - *

Range Constructor.

- * - *

Constructs a container with as many elements as the range (begin, end), with each - * element emplace-constructed from its corresponding element in that range, in the same order.

- * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * @inheritdoc - */ - assign>(begin: InputIterator, end: InputIterator): void; - /** - * @inheritdoc - */ - assign(n: number, val: T): void; - /** - * @inheritdoc - */ - reserve(capacity: number): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - begin(): DequeIterator; - /** - * @inheritdoc - */ - end(): DequeIterator; - /** - * @inheritdoc - */ - rbegin(): DequeReverseIterator; - /** - * @inheritdoc - */ - rend(): DequeReverseIterator; - /** - * @inheritdoc - */ - size(): number; - /** - * @inheritdoc - */ - empty(): boolean; - /** - * @inheritdoc - */ - capacity(): number; - /** - * @inheritdoc - */ - at(index: number): T; - /** - * @inheritdoc - */ - set(index: number, val: T): void; - /** - * @inheritdoc - */ - front(): T; - /** - * @inheritdoc - */ - back(): T; - /** - // Fetch row and column's index. - /** - * @hidden - */ - private fetch_index(index); - /** - * @inheritdoc - */ - push(...items: T[]): number; - /** - * @inheritdoc - */ - push_front(val: T): void; - /** - * @inheritdoc - */ - push_back(val: T): void; - /** - * @inheritdoc - */ - pop_front(): void; - /** - * @inheritdoc - */ - pop_back(): void; - /** - * @inheritdoc - */ - insert(position: DequeIterator, val: T): DequeIterator; - /** - * @inheritdoc - */ - insert(position: DequeIterator, n: number, val: T): DequeIterator; - /** - * @inheritdoc - */ - insert>(position: DequeIterator, begin: InputIterator, end: InputIterator): DequeIterator; - /** - * @inheritdoc - */ - insert(position: DequeReverseIterator, val: T): DequeReverseIterator; - /** - * @inheritdoc - */ - insert(position: DequeReverseIterator, n: number, val: T): DequeReverseIterator; - /** - * @inheritdoc - */ - insert>(position: DequeReverseIterator, begin: InputIterator, end: InputIterator): DequeReverseIterator; - /** - * @hidden - */ - private insert_by_val(position, val); - /** - * @hidden - */ - protected _Insert_by_repeating_val(position: DequeIterator, n: number, val: T): DequeIterator; - /** - * @hidden - */ - protected _Insert_by_range>(position: DequeIterator, begin: InputIterator, end: InputIterator): DequeIterator; - /** - * @hidden - */ - private insert_by_items(position, items); - /** - * @inheritdoc - */ - erase(position: DequeIterator): DequeIterator; - /** - * @inheritdoc - */ - erase(first: DequeIterator, last: DequeIterator): DequeIterator; - /** - * @inheritdoc - */ - erase(position: DequeReverseIterator): DequeReverseIterator; - /** - * @inheritdoc - */ - erase(first: DequeReverseIterator, last: DequeReverseIterator): DequeReverseIterator; - /** - * @hidden - */ - protected _Erase_by_range(first: DequeIterator, last: DequeIterator): DequeIterator; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link Deque container} object with same type of elements. Sizes and container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were in obj - * before the call, and the elements of obj are those which were in this. All iterators, references and - * pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link Deque container} of the same type of elements (i.e., instantiated - * with the same template parameter, T) whose content is swapped with that of this - * {@link container Deque}. - */ - swap(obj: Deque): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } -} -declare namespace std { - /** - *

An iterator of {@link Deque}.

- * - *

- * - *

- * - * @author Jeongho Nam - */ - class DequeIterator extends Iterator implements base.IArrayIterator { - /** - * Sequence number of iterator in the source {@link Deque}. - */ - private index_; - /** - *

Construct from the source {@link Deque container}.

- * - *

Note

- *

Do not create the iterator directly, by yourself.

- *

Use {@link Deque.begin begin()}, {@link Deque.end end()} in {@link Deque container} instead.

- * - * @param source The source {@link Deque container} to reference. - * @param index Sequence number of the element in the source {@link Deque}. - */ - constructor(source: Deque, index: number); - /** - * @hidden - */ - private deque; - /** - * @inheritdoc - */ - /** - * Set value of the iterator is pointing to. - * - * @param val Value to set. - */ - value: T; - /** - * @inheritdoc - */ - index: number; - /** - * @inheritdoc - */ - prev(): DequeIterator; - /** - * @inheritdoc - */ - next(): DequeIterator; - /** - * @inheritdoc - */ - advance(n: number): DequeIterator; - /** - *

Whether an iterator is equal with the iterator.

- * - *

Compare two iterators and returns whether they are equal or not.

- * - *

Note

- *

Iterator's equal_to() only compare souce container and index number.

- * - *

Although elements in a pair, key and value are equal_to, if the source map or - * index number is different, then the {@link equal_to equal_to()} will return false. If you want to - * compare the elements of a pair, compare them directly by yourself.

- * - * @param obj An iterator to compare - * @return Indicates whether equal or not. - */ - equal_to(obj: DequeIterator): boolean; - /** - * @inheritdoc - */ - swap(obj: DequeIterator): void; - } -} -declare namespace std { - /** - *

A reverse-iterator of Deque.

- * - *

- * - *

- * - * @param Type of the elements. - * - * @author Jeongho Nam - */ - class DequeReverseIterator extends ReverseIterator, DequeReverseIterator> implements base.IArrayIterator { - /** - * Construct from base iterator. - * - * @param base A reference of the base iterator, which iterates in the opposite direction. - */ - constructor(base: DequeIterator); - /** - * @hidden - */ - protected create_neighbor(base: DequeIterator): DequeReverseIterator; - /** - * @inheritdoc - */ - /** - * Set value of the iterator is pointing to. - * - * @param val Value to set. - */ - value: T; - /** - * Get index. - */ - index: number; - } -} -declare namespace std { - /** - *

Function handling termination on exception

- * - *

Calls the current terminate handler.

- * - *

By default, the terminate handler calls abort. But this behavior can be redefined by calling - * {@link set_terminate}.

- * - *

This function is automatically called when no catch handler can be found for a thrown exception, - * or for some other exceptional circumstance that makes impossible to continue the exception handling process.

- * - *

This function is provided so that the terminate handler can be explicitly called by a program that needs to - * abnormally terminate, and works even if {@link set_terminate} has not been used to set a custom terminate handler - * (calling abort in this case).

- */ - function terminate(): void; - /** - *

Set terminate handler function.

- * - *

A terminate handler function is a function automatically called when the exception handling process has - * to be abandoned for some reason. This happens when no catch handler can be found for a thrown exception, or for - * some other exceptional circumstance that makes impossible to continue the exception handling process.

- * - *

Before this function is called by the program for the first time, the default behavior is to call abort.

- * - *

A program may explicitly call the current terminate handler function by calling {@link terminate}.

- * - * @param f Function that takes no parameters and returns no value (void). - */ - function set_terminate(f: () => void): void; - /** - *

Get terminate handler function.

- * - *

The terminate handler function is automatically called when no catch handler can be found - * for a thrown exception, or for some other exceptional circumstance that makes impossible to continue the exception - * handling process.

- * - *

If no such function has been set by a previous call to {@link set_terminate}, the function returns a - * null-pointer.

- * - * @return If {@link set_terminate} has previously been called by the program, the function returns the current - * terminate handler function. Otherwise, it returns a null-pointer. - */ - function get_terminate(): () => void; - /** - *

Standard exception class.

- * - *

Base class for standard exceptions.

- * - *

All objects thrown by components of the standard library are derived from this class. - * Therefore, all standard exceptions can be caught by catching this type by reference.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/exception/exception - * @author Jeongho Nam - */ - class Exception extends Error { - /** - * A message representing specification about the Exception. - */ - private description; - /** - * Default Constructor. - */ - constructor(); - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - /** - *

Get string identifying exception.

- *

Returns a string that may be used to identify the exception.

- * - *

The particular representation pointed by the returned value is implementation-defined. - * As a virtual function, derived classes may redefine this function so that specify value are - * returned.

- */ - what(): string; - /** - * @inheritdoc - */ - message: string; - /** - * @inheritdoc - */ - name: string; - } - /** - *

Logic error exception.

- * - *

This class defines the type of objects thrown as exceptions to report errors in the internal - * logical of the program, such as violation of logical preconditions or class invariants.

- * - *

These errors are presumably detectable before the program executes.

- * - *

It is used as a base class for several logical error exceptions.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/logic_error - * @author Jeongho Nam - */ - class LogicError extends Exception { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Domain error exception.

- * - *

This class defines the type of objects thrown as exceptions to report domain errors.

- * - *

Generally, the domain of a mathematical function is the subset of values that it is defined for. - * For example, the square root function is only defined for non-negative numbers. Thus, a negative number - * for such a function would qualify as a domain error.

- * - *

No component of the standard library throws exceptions of this type. It is designed as a standard - * exception to be thrown by programs.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/domain_error - * @author Jeongho Nam - */ - class DomainError extends LogicError { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Invalid argument exception.

- * - *

This class defines the type of objects thrown as exceptions to report an invalid argument.

- * - *

It is a standard exception that can be thrown by programs. Some components of the standard library - * also throw exceptions of this type to signal invalid arguments.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/invalid_argument - * @author Jeongho Nam - */ - class InvalidArgument extends LogicError { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Length error exception.

- * - *

This class defines the type of objects thrown as exceptions to report a length error.

- * - *

It is a standard exception that can be thrown by programs. Some components of the standard library, - * such as vector and string also throw exceptions of this type to signal errors resizing.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/length_error - * @author Jeongho Nam - */ - class LengthError extends LogicError { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Out-of-range exception.

- * - *

This class defines the type of objects thrown as exceptions to report an out-of-range error.

- * - *

It is a standard exception that can be thrown by programs. Some components of the standard library, - * such as vector, deque, string and bitset also throw exceptions of this type to signal arguments - * out of range.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/out_of_range - * @author Jeongho Nam - */ - class OutOfRange extends LogicError { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Runtime error exception.

- * - *

This class defines the type of objects thrown as exceptions to report errors that can only be - * detected during runtime.

- * - *

It is used as a base class for several runtime error exceptions.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/runtime_error - * @author Jeongho Nam - */ - class RuntimeError extends Exception { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Overflow error exception.

- * - *

This class defines the type of objects thrown as exceptions to arithmetic overflow errors.

- * - *

It is a standard exception that can be thrown by programs. Some components of the standard library - * also throw exceptions of this type to signal range errors.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/overflow_error - * @author Jeongho Nam - */ - class OverflowError extends RuntimeError { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Underflow error exception.

- * - *

This class defines the type of objects thrown as exceptions to arithmetic underflow errors.

- * - *

No component of the standard library throws exceptions of this type. It is designed as a standard - * exception to be thrown by programs.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/underflow_error - * @author Jeongho Nam - */ - class UnderflowError extends RuntimeError { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } - /** - *

Range error exception.

- * - *

This class defines the type of objects thrown as exceptions to report range errors in internal - * computations.

- * - *

It is a standard exception that can be thrown by programs. Some components of the standard library - * also throw exceptions of this type to signal range errors.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/stdexcept/range_error - * @author Jeongho Nam - */ - class RangeError extends RuntimeError { - /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. - */ - constructor(message: string); - } -} -declare namespace std { - /** - *

Function object class for equality comparison.

- * - *

Binary function object class whose call returns whether its two arguments compare equal (as returned by - * operator ==).

- * - *

Generically, function objects are instances of a class with member function {@link IComparable.equal_to equal_to} - * defined. This member function allows the object to be used with the same syntax as a function call.

- * - * @param x First element to compare. - * @param y Second element to compare. - * - * @return Whether the arguments are equal. - */ - function equal_to(x: T, y: T): boolean; - /** - *

Function object class for non-equality comparison.

- * - *

Binary function object class whose call returns whether its two arguments compare not equal (as returned - * by operator operator!=).

- * - *

Generically, function objects are instances of a class with member function {@link IComparable.equal_to equal_to} - * defined. This member function allows the object to be used with the same syntax as a function call.

- * - * @param x First element to compare. - * @param y Second element to compare. - * - * @return Whether the arguments are not equal. - */ - function not_equal_to(x: T, y: T): boolean; - /** - *

Function for less-than inequality comparison.

- * - *

Binary function returns whether the its first argument compares less than the second.

- * - *

Generically, function objects are instances of a class with member function {@link IComparable.less less} - * defined. If an object doesn't have the method, then its own uid will be used to compare insteadly. - * This member function allows the object to be used with the same syntax as a function call.

- * - *

Objects of this class can be used on standard algorithms such as {@link sort sort()}, - * {@link merge merge()} or {@link TreeMap.lower_bound lower_bound()}.

- * - * @param Type of arguments to compare by the function call. The type shall supporrt the operation - * operator<() or method {@link IComparable.less less}. - * - * @param x First element, the standard of comparison. - * @param y Second element compare with the first. - * - * @return Whether the first parameter is less than the second. - */ - function less(x: T, y: T): boolean; - /** - *

Function object class for less-than-or-equal-to comparison.

- * - *

Binary function object class whose call returns whether the its first argument compares {@link less less than} or - * {@link equal_to equal to} the second (as returned by operator <=).

- * - *

Generically, function objects are instances of a class with member function {@link IComparable.less less} - * and {@link IComparable.equal_to equal_to} defined. This member function allows the object to be used with the same - * syntax as a function call.

- * - * @param x First element, the standard of comparison. - * @param y Second element compare with the first. - * - * @return Whether the x is {@link less less than} or {@link equal_to equal to} the y. - */ - function less_equal(x: T, y: T): boolean; - /** - *

Function for greater-than inequality comparison.

- * - *

Binary function returns whether the its first argument compares greater than the second.

- * - *

Generically, function objects are instances of a class with member function {@link less} and - * {@link equal_to equal_to()} defined. If an object doesn't have those methods, then its own uid will be used - * to compare insteadly. This member function allows the object to be used with the same syntax as a function - * call.

- * - *

Objects of this class can be used on standard algorithms such as {@link sort sort()}, - * {@link merge merge()} or {@link TreeMap.lower_bound lower_bound()}.

- * - * @param Type of arguments to compare by the function call. The type shall supporrt the operation - * operator>() or method {@link IComparable.greater greater}. - * - * @return Whether the x is greater than the y. - */ - function greater(x: T, y: T): boolean; - /** - *

Function object class for greater-than-or-equal-to comparison.

- * - *

Binary function object class whose call returns whether the its first argument compares - * {@link greater greater than} or {@link equal_to equal to} the second (as returned by operator >=).

- * - *

Generically, function objects are instances of a class with member function {@link IComparable.less less} - * defined. If an object doesn't have the method, then its own uid will be used to compare insteadly. - * This member function allows the object to be used with the same syntax as a function call.

- * - * @param x First element, the standard of comparison. - * @param y Second element compare with the first. - * - * @return Whether the x is {@link greater greater than} or {@link equal_to equal to} the y. - */ - function greater_equal(x: T, y: T): boolean; - /** - *

Logical AND function object class.

- * - *

Binary function object class whose call returns the result of the logical "and" operation between its two - * arguments (as returned by operator &&).

- * - *

Generically, function objects are instances of a class with member function operator() defined. This member - * function allows the object to be used with the same syntax as a function call.

- * - * @param x First element. - * @param y Second element. - * - * @return Result of logical AND operation. - */ - function logical_and(x: T, y: T): boolean; - /** - *

Logical OR function object class.

- * - *

Binary function object class whose call returns the result of the logical "or" operation between its two - * arguments (as returned by operator ||).

- * - *

Generically, function objects are instances of a class with member function operator() defined. This member - * function allows the object to be used with the same syntax as a function call.

- * - * @param x First element. - * @param y Second element. - * - * @return Result of logical OR operation. - */ - function logical_or(x: T, y: T): boolean; - /** - *

Logical NOT function object class.

- * - *

Unary function object class whose call returns the result of the logical "not" operation on its argument - * (as returned by operator !).

- * - *

Generically, function objects are instances of a class with member function operator() defined. This member - * function allows the object to be used with the same syntax as a function call.

- * - * @param x Target element. - * - * @return Result of logical NOT operation. - */ - function logical_not(x: T): boolean; - /** - *

Bitwise AND function object class.

- * - *

Binary function object class whose call returns the result of applying the bitwise "and" operation between - * its two arguments (as returned by operator &).

- * - * @param x First element. - * @param y Second element. - * - * @return Result of bitwise AND operation. - */ - function bit_and(x: number, y: number): number; - /** - *

Bitwise OR function object class.

- * - *

Binary function object class whose call returns the result of applying the bitwise "and" operation between - * its two arguments (as returned by operator &).

- * - * @param x First element. - * @param y Second element. - * - * @return Result of bitwise OR operation. - */ - function bit_or(x: number, y: number): number; - /** - *

Bitwise XOR function object class.

- * - *

Binary function object class whose call returns the result of applying the bitwise "exclusive or" - * operation between its two arguments (as returned by operator ^).

- * - * @param x First element. - * @param y Second element. - * - * @return Result of bitwise XOR operation. - */ - function bit_xor(x: number, y: number): number; - /** - *

Comparable instance.

- * - *

{@link IComparable} is a common interface for objects who can compare each other.

- * - * @reference https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html - * @author Jeongho Nam - */ - interface IComparable extends Object { - /** - *

Indicates whether some other object is "equal to" this one.

- * - *

The {@link equal_to} method implements an equivalence relation on non-null object references:

- * - *
    - *
  • - * It is reflexive: for any non-null reference value x, x.equal_to(x) - * should return true. - *
  • - *
  • - * It is symmetric: for any non-null reference values x and y, - * x.equal_to(y) should return true if and only if y.equal_to(x) - * returns true.
  • - *
  • - * It is transitive: for any non-null reference values x, y, and - * z, if x.equal_to(y) returns true and y.equal_to(z) - * returns true, then x.equal_to(z) should return true. - *
  • - *
  • - * It is consistent: for any non-null reference values x and y, multiple - * invocations of x.equal_to(y) consistently return true or consistently return - * false, provided no information used in equal_to comparisons on the objects is modified. - *
  • - *
  • - * For any non-null reference value x, x.equal_to(null) should return - * false. - *
  • - *
- * - *

The {@link equal_to} method for interface {@link IComparable} implements the most discriminating possible - * equivalence relation on objects; that is, for any non-null reference values x and - * y, this method returns true if and only if x and y - * refer to the same object (x == y has the value true).

- * - *

Note that it is generally necessary to override the {@link hash_code} method whenever this method is - * overridden, so as to maintain the general contract for the {@link hash_code} method, which states that - * equal objects must have equal hash codes.

- * - *
    - *
  • {@link IComparable.equal_to} is called by {@link std.equal_to}.
  • - *
- * - * @param obj the reference object with which to compare. - * - * @return true if this object is the same as the obj argument; false otherwise. - */ - equal_to(obj: T): boolean; - /** - *

Less-than inequality comparison.

- * - *

Binary method returns whether the the instance compares less than the obj.

- * - *
    - *
  • - * {@link IComparable.less} is called by {@link std.less}. Also, this method can be used on standard - * algorithms such as {@link sort sort()}, {@link merge merge()} or - * {@link TreeMap.lower_bound lower_bound()}. - *
  • - *
- * - * @param obj the reference object with which to compare. - * - * @return Whether the first parameter is less than the second. - */ - less(obj: T): boolean; - /** - *

Issue a hash code.

- * - *

Returns a hash code value for the object. This method is supported for the benefit of hash tables such - * as those provided by hash containers; {@link HashSet}, {@link HashMap}, {@link MultiHashSet} and - * {@link MultiHashMap}.

- * - *

As much as is reasonably practical, the {@link hash_code} method defined by interface - * {@link IComparable} does return distinct integers for distinct objects. (This is typically implemented by - * converting the internal address of the object into an integer, but this implementation technique is not - * required by the JavaScript programming language.)

- * - *
    - *
  • - * {@link IComparable.hash_code} is called by {@link std.hash_code}. If you want to keep basically - * provided hash function, then returns {@link std.Hash.code}; return std.Hash.code(this); - *
  • - *
- * - * @return An hash code who represents the object. - */ - hash(): number; - } - /** - *

Default hash function for number.

- * - *

Unary function that defines the default hash function used by the standard library.

- * - *

The functional call returns a hash value of its argument: A hash value is a value that depends solely on - * its argument, returning always the same value for the same argument (for a given execution of a program). The - * value returned shall have a small likelihood of being the same as the one returned for a different argument. - *

- * - * @param val Value to be hashed. - * - * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. - */ - function hash(val: number): number; - /** - *

Default hash function for string.

- * - *

Unary function that defines the default hash function used by the standard library.

- * - *

The functional call returns a hash value of its argument: A hash value is a value that depends solely on - * its argument, returning always the same value for the same argument (for a given execution of a program). The - * value returned shall have a small likelihood of being the same as the one returned for a different argument. - *

- * - * @param str A string to be hashed. - * - * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. - */ - function hash(str: string): number; - /** - *

Default hash function for Object.

- * - *

Unary function that defines the default hash function used by the standard library.

- * - *

The functional call returns a hash value of its argument: A hash value is a value that depends solely on - * its argument, returning always the same value for the same argument (for a given execution of a program). The - * value returned shall have a small likelihood of being the same as the one returned for a different argument. - *

- * - *

The default {@link hash} function of Object returns a value returned from {@link hash hash(number)} with - * an unique id of each Object. If you want to specify {@link hash} function of a specific class, then - * define a member function public hash(): number in the class.

- * - * @param obj Object to be hashed. - * - * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. - */ - function hash(obj: Object): number; - /** - *

Exchange contents of {@link IContainers containers}.

- * - *

The contents of container left are exchanged with those of right. Both container objects must have - * same type of elements (same template parameters), although sizes may differ.

- * - *

After the call to this member function, the elements in left are those which were in right before - * the call, and the elements of right are those which were in left. All iterators, references and - * pointers remain valid for the swapped objects.

- * - *

This is an overload of the generic algorithm swap that improves its performance by mutually transferring - * ownership over their assets to the other container (i.e., the containers exchange references to their data, without - * actually performing any element copy or movement): It behaves as if left. - * {@link IContainer.swap swap}(right) was called.

- * - * @param left A {@link IContainer container} to swap its contents. - * @param right A {@link IContainer container} to swap its contents. - */ - function swap(left: base.IContainer, right: base.IContainer): void; - /** - *

Exchange contents of queues.

- * - *

Exchanges the contents of left and right.

- * - * @param left A {@link Queue} container of the same type. Size may differ. - * @param right A {@link Queue} container of the same type. Size may differ. - */ - function swap(left: Queue, right: Queue): void; - /** - *

Exchange contents of {@link PriorityQueue PriorityQueues}.

- * - *

Exchanges the contents of left and right.

- * - * @param left A {@link PriorityQueue} container of the same type. Size may differ. - * @param right A {@link PriorityQueue} container of the same type. Size may differ. - */ - function swap(left: PriorityQueue, right: PriorityQueue): void; - /** - *

Exchange contents of {@link Stack Stacks}.

- * - *

Exchanges the contents of left and right.

- * - * @param left A {@link Stack} container of the same type. Size may differ. - * @param right A {@link Stack} container of the same type. Size may differ. - */ - function swap(left: Stack, right: Stack): void; - /** - *

Exchanges the contents of two {@link UniqueMap unique maps}.

- * - *

The contents of container left are exchanged with those of right. Both container objects must - * be of the same type (same template parameters), although sizes may differ.

- * - *

After the call to this member function, the elements in left are those which were in right - * before the call, and the elements of right are those which were in left. All iterators, references - * and pointers remain valid for the swapped objects.

- * - *

This is an overload of the generic algorithm swap that improves its performance by mutually transferring - * ownership over their assets to the other container (i.e., the containers exchange references to their data, - * without actually performing any element copy or movement): It behaves as if - * left.{@link UniqueMap.swap swap}(right) was called.

- * - * @param left An {@link UniqueMap unique map} to swap its conents. - * @param right An {@link UniqueMap unique map} to swap its conents. - */ - function swap(left: base.UniqueMap, right: base.UniqueMap): void; - /** - *

Exchanges the contents of two {@link MultiMap multi maps}.

- * - *

The contents of container left are exchanged with those of right. Both container objects must - * be of the same type (same template parameters), although sizes may differ.

- * - *

After the call to this member function, the elements in left are those which were in right - * before the call, and the elements of right are those which were in left. All iterators, references - * and pointers remain valid for the swapped objects.

- * - *

This is an overload of the generic algorithm swap that improves its performance by mutually transferring - * ownership over their assets to the other container (i.e., the containers exchange references to their data, - * without actually performing any element copy or movement): It behaves as if - * left.{@link MultiMap.swap swap}(right) was called.

- * - * @param left A {@link MultiMap multi map} to swap its conents. - * @param right A {@link MultiMap multi map} to swap its conents. - */ - function swap(left: base.MultiMap, right: base.MultiMap): void; -} -declare namespace std { - /** - *

Bind function arguments.

- * - *

Returns a function object based on fn, but with its arguments bound to args.

- * - *

Each argument may either be bound to a value or be a {@link placeholders placeholder}:

- *
    - *
  • If bound to a value, calling the returned function object will always use that value as argument.
  • - *
  • - * If a {@link placeholders placeholder}, calling the returned function object forwards an argument passed to the - * call (the one whose order number is specified by the placeholder). - *
  • - *
- * - *

Calling the returned object returns the same type as fn.

- * - * @param fn A function object, pointer to function or pointer to member. - * @param args List of arguments to bind: either values, or {@link placeholders}. - * - * @return A function object that, when called, calls fn with its arguments bound to args. If fn is - * a pointer to member, the first argument expected by the returned function is an object of the class fn - * is a member. - */ - function bind(fn: (...args: any[]) => Ret, ...args: any[]): (...args: any[]) => Ret; - /** - *

Bind function arguments.

- * - *

Returns a function object based on fn, but with its arguments bound to args.

- * - *

Each argument may either be bound to a value or be a {@link placeholders placeholder}:

- *
    - *
  • If bound to a value, calling the returned function object will always use that value as argument.
  • - *
  • - * If a {@link placeholders placeholder}, calling the returned function object forwards an argument passed to the - * call (the one whose order number is specified by the placeholder). - *
  • - *
- * - *

Calling the returned object returns the same type as fn.

- * - * @param fn A function object, pointer to function or pointer to member. - * @param thisArg This argument, owner object of the member method fn. - * @param args List of arguments to bind: either values, or {@link placeholders}. - * - * @return A function object that, when called, calls fn with its arguments bound to args. If fn is - * a pointer to member, the first argument expected by the returned function is an object of the class fn - * is a member. - */ - function bind(fn: (...args: any[]) => Ret, thisArg: T, ...args: any[]): (...args: any[]) => Ret; -} -/** - *

Bind argument placeholders.

- * - *
- * - *

When the function object returned by bind is called, an argument with placeholder {@link _1} is replaced by the - * first argument in the call, {@link _2} is replaced by the second argument in the call, and so on... For example:

- * - * - * let vec: Vector = new Vector(); - * - * let bind = std.bind(Vector.insert, _1, vec.end(), _2, _3); - * bind.apply(vec, 5, 1); // vec.insert(vec.end(), 5, 1); - * // [1, 1, 1, 1, 1] - * - * - *

When a call to {@link bind} is used as a subexpression in another call to bind, the {@link placeholders} - * are relative to the outermost {@link bind} expression.

- * - * @reference http://www.cplusplus.com/reference/functional/placeholders/ - * @author Jeongho Nam - */ -declare namespace std.placeholders { - /** - * @hidden - */ - class PlaceHolder { - private index_; - constructor(index: number); - index: number; - } - /** - * Replaced by the first argument in the function call. - */ - const _1: PlaceHolder; - /** - * Replaced by the second argument in the function call. - */ - const _2: PlaceHolder; - /** - * Replaced by the third argument in the function call. - */ - const _3: PlaceHolder; - const _4: PlaceHolder; - const _5: PlaceHolder; - const _6: PlaceHolder; - const _7: PlaceHolder; - const _8: PlaceHolder; - const _9: PlaceHolder; - const _10: PlaceHolder; - const _11: PlaceHolder; - const _12: PlaceHolder; - const _13: PlaceHolder; - const _14: PlaceHolder; - const _15: PlaceHolder; - const _16: PlaceHolder; - const _17: PlaceHolder; - const _18: PlaceHolder; - const _19: PlaceHolder; - const _20: PlaceHolder; -} -declare namespace std.base { - /** - *

An abstract map.

- * - *

{@link MapContainer MapContainers} are associative containers that store elements formed by a combination - * of a key value (Key) and a mapped value (T), and which allows for fast retrieval - * of individual elements based on their keys.

- * - *

In a {@link MapContainer}, the key values are generally used to identify the elements, while the - * mapped values store the content associated to this key. The types of key and - * mapped value may differ, and are grouped together in member type value_type, which is a - * {@link Pair} type combining both:

- * - *

typedef pair value_type;

- * - *

{@link MapContainer} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute position - * in the container. - *
- * - *
Map
- *
- * Each element associates a key to a mapped value: - * Keys are meant to identify the elements whose main content is the mapped value. - *
- *
- * - * @param Type of the keys. Each element in a map is identified by its key value. - * @param Type of the mapped value. Each element in a map stores some data as its mapped value. - * - * @author Jeongho Nam - */ - abstract class MapContainer extends Container> { - /** - *

{@link List} storing elements.

- * - *

Storing elements and keeping those sequence of the {@link MapContainer} are implemented by - * {@link data_ this list container}. Implementing index-table is also related with {@link data_ this list} - * by storing {@link ListIterator iterators} ({@link MapIterator} references {@link ListIterator}) who are - * created from {@link data_ here}.

- */ - private data_; - /** - * Default Constructor. - */ - constructor(); - /** - * @inheritdoc - */ - assign>>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - clear(): void; - /** - *

Get iterator to element.

- * - *

Searches the container for an element with a identifier equivalent to key and returns an - * iterator to it if found, otherwise it returns an iterator to {@link end end()}.

- * - *

Two keys are considered equivalent if the container's comparison object returns false reflexively - * (i.e., no matter the order in which the elements are passed as arguments).

- * - *

Another member functions, {@link has has()} and {@link count count()}, can be used to just check - * whether a particular key exists.

- * - * @param key Key to be searched for - * @return An iterator to the element, if an element with specified key is found, or - * {@link end end()} otherwise. - */ - abstract find(key: Key): MapIterator; - /** - *

Return iterator to beginning.

- * - *

Returns an iterator referring the first element in the

- * - *

Note

- *

If the container is {@link empty}, the returned iterator is same with {@link end end()}.

- * - * @return An iterator to the first element in the The iterator containes the first element's value. - */ - begin(): MapIterator; - /** - *

Return iterator to end.

- *

Returns an iterator referring to the past-the-end element in the

- * - *

The past-the-end element is the theoretical element that would follow the last element in the - * It does not point to any element, and thus shall not be dereferenced.

- * - *

Because the ranges used by functions of the container do not include the element reference by their - * closing iterator, this function is often used in combination with {@link MapContainer}.{@link begin} to - * specify a range including all the elements in the

- * - *

Note

- *

Returned iterator from {@link MapContainer}.{@link end} does not refer any element. Trying to accessing - * element by the iterator will cause throwing exception ({@link OutOfRange}).

- * - *

If the container is {@link empty}, this function returns the same as {@link begin}.

- * - * @return An iterator to the end element in the - */ - end(): MapIterator; - /** - *

Return {@link MapReverseIterator reverse iterator} to reverse beginning.

- * - *

Returns a {@link MapReverseIterator reverse iterator} pointing to the last element in the container - * (i.e., its reverse beginning).

- * - * {@link MapReverseIterator Reverse iterators} iterate backwards: increasing them moves them towards the - * beginning of the container.

- * - *

{@link rbegin} points to the element preceding the one that would be pointed to by member {@link end}. - *

- * - * @return A {@link MapReverseIterator reverse iterator} to the reverse beginning of the sequence - * - */ - rbegin(): MapReverseIterator; - /** - *

Return {@link MapReverseIterator reverse iterator} to reverse end.

- * - *

Returns a {@link MapReverseIterator reverse iterator} pointing to the theoretical element right before - * the first element in the {@link MapContainer map container} (which is considered its reverse end). - *

- * - *

The range between {@link MapContainer}.{@link rbegin} and {@link MapContainer}.{@link rend} contains - * all the elements of the container (in reverse order).

- * - * @return A {@link MapReverseIterator reverse iterator} to the reverse end of the sequence - */ - rend(): MapReverseIterator; - /** - *

Whether have the item or not.

- * - *

Indicates whether a map has an item having the specified identifier.

- * - * @param key Key value of the element whose mapped value is accessed. - * - * @return Whether the map has an item having the specified identifier. - */ - has(key: Key): boolean; - /** - *

Count elements with a specific key.

- * - *

Searches the container for elements whose key is key and returns the number of elements found.

- * - * @param key Key value to be searched for. - * - * @return The number of elements in the container with a key. - */ - abstract count(key: Key): number; - /** - * Return the number of elements in the map. - */ - size(): number; - protected _Get_data(): List>; - /** - * @inheritdoc - */ - push(...args: Pair[]): number; - /** - * @inheritdoc - */ - push(...args: [Key, T][]): number; - /** - *

Insert an element.

- * - *

Extends the container by inserting a new element, effectively increasing the container {@link size} - * by the number of element inserted (zero or one).

- * - * @param hint Hint for the position where the element can be inserted. - * @param pair {@link Pair} to be inserted as an element. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had an - * equivalent key in the {@link MapContainer}. - */ - insert(hint: MapIterator, pair: Pair): MapIterator; - /** - *

Insert an element.

- * - *

Extends the container by inserting a new element, effectively increasing the container {@link size} - * by the number of element inserted (zero or one).

- * - * @param hint Hint for the position where the element can be inserted. - * @param pair {@link Pair} to be inserted as an element. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had an - * equivalent key in the {@link MapContainer}. - */ - insert(hint: MapReverseIterator, pair: Pair): MapReverseIterator; - /** - *

Insert an element.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} - * by the number of elements inserted.

- * - * @param hint Hint for the position where the element can be inserted. - * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had an - * equivalent key in the {@link MapContainer}. - */ - insert(hint: MapIterator, tuple: [L, U]): MapIterator; - /** - *

Insert an element.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} - * by the number of elements inserted.

- * - * @param hint Hint for the position where the element can be inserted. - * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had an - * equivalent key in the {@link MapContainer}. - */ - insert(hint: MapReverseIterator, tuple: [L, U]): MapReverseIterator; - /** - *

Insert elements from range iterators.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} by - * the number of elements inserted.

- * - * @param begin Input iterator specifying initial position of a range of elements. - * @param end Input iterator specifying final position of a range of elements. - * Notice that the range includes all the elements between begin and end, - * including the element pointed by begin but not the one pointed by end. - */ - insert>>(first: InputIterator, last: InputIterator): void; - /** - * @hidden - */ - protected abstract _Insert_by_pair(pair: Pair): any; - /** - * @hidden - */ - private insert_by_tuple(tuple); - /** - * @hidden - */ - protected abstract _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; - /** - * @hidden - */ - private insert_by_hint_with_tuple(hint, tuple); - /** - * @hidden - */ - protected abstract _Insert_by_range>>(first: InputIterator, last: InputIterator): void; - /** - *

Erase an elemet by key.

- * - *

Removes from the {@link MapContainer map container} a single element.

- * - *

This effectively reduces the container {@link size} by the number of element removed (zero or one), - * which are destroyed.

- * - * @param key Key of the element to be removed from the {@link MapContainer}. - */ - erase(key: Key): number; - /** - *

Erase an elemet by iterator.

- * - *

Removes from the {@link MapContainer map container} a single element.

- * - *

This effectively reduces the container {@link size} by the number of element removed (zero or one), - * which are destroyed.

- * - * @param it Iterator specifying position winthin the {@link MapContainer map contaier} to be removed. - */ - erase(it: MapIterator): MapIterator; - /** - *

Erase elements by range iterators.

- * - *

Removes from the {@link MapContainer map container} a range of elements.

- * - *

This effectively reduces the container {@link size} by the number of elements removed, which are - * destroyed.

- * - * @param begin An iterator specifying initial position of a range within {@link MApContainer map container} - * to be removed. - * @param end An iterator specifying initial position of a range within {@link MApContainer map container} - * to be removed. - * Notice that the range includes all the elements between begin and end, - * including the element pointed by begin but not the one pointed by end. - */ - erase(begin: MapIterator, end: MapIterator): MapIterator; - /** - *

Erase an elemet by iterator.

- * - *

Removes from the {@link MapContainer map container} a single element.

- * - *

This effectively reduces the container {@link size} by the number of element removed (zero or one), - * which are destroyed.

- * - * @param it Iterator specifying position winthin the {@link MapContainer map contaier} to be removed. - */ - erase(it: MapReverseIterator): MapReverseIterator; - /** - *

Erase elements by range iterators.

- * - *

Removes from the {@link MapContainer map container} a range of elements.

- * - *

This effectively reduces the container {@link size} by the number of elements removed, which are - * destroyed.

- * - * @param begin An iterator specifying initial position of a range within {@link MApContainer map container} - * to be removed. - * @param end An iterator specifying initial position of a range within {@link MApContainer map container} - * to be removed. - * Notice that the range includes all the elements between begin and end, - * including the element pointed by begin but not the one pointed by end. - */ - erase(begin: MapReverseIterator, end: MapReverseIterator): MapReverseIterator; - /** - * @hidden - */ - private erase_by_key(key); - /** - * @hidden - */ - private erase_by_iterator(first, last?); - /** - * @hidden - */ - private erase_by_range(begin, end); - /** - *

Abstract method handling insertions for indexing.

- * - *

This method, {@link handle_insert} is designed to register the first to last to somewhere storing - * those {@link MapIterator iterators} for indexing, fast accessment and retrievalance.

- * - *

When {@link insert} is called, new elements will be inserted into the {@link data_ list container} and new - * {@link MapIterator iterators} first to last, pointing the inserted elements, will be created and the - * newly created iterators first to last will be shifted into this method {@link handle_insert} after the - * insertions.

- * - *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link MapIterator iterators} - * will be registered into the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the - * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be - * registered into the {@link HashSet.hash_buckets_ hash bucket}.

- * - * @param first An {@link MapIterator} to the initial position in a sequence. - * @param last An {@link MapIterator} to the final position in a sequence. The range used is - * [first, last), which contains all the elements between first and last, - * including the element pointed by first but not the element pointed by last. - */ - protected abstract _Handle_insert(first: MapIterator, last: MapIterator): void; - /** - *

Abstract method handling deletions for indexing.

- * - *

This method, {@link handle_insert} is designed to unregister the first to last to somewhere storing - * those {@link MapIterator iterators} for indexing, fast accessment and retrievalance.

- * - *

When {@link erase} is called with first to last, {@link MapIterator iterators} positioning somewhere - * place to be deleted, is memorized and shifted to this method {@link handle_erase} after the deletion process is - * terminated.

- * - *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link MapIterator iterators} - * will be unregistered from the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the - * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be - * unregistered from the {@link HashSet.hash_buckets_ hash bucket}.

- * - * @param first An {@link MapIterator} to the initial position in a sequence. - * @param last An {@link MapIterator} to the final position in a sequence. The range used is - * [first, last), which contains all the elements between first and last, - * including the element pointed by first but not the element pointed by last. - */ - protected abstract _Handle_erase(first: MapIterator, last: MapIterator): void; - /** - * @hidden - */ - protected _Swap(obj: MapContainer): void; - } -} -declare namespace std { - /** - *

An iterator of {@link MapContainer map container}.

- * - *

- *

- * - * @author Jeongho Nam - */ - class MapIterator extends Iterator> implements IComparable> { - /** - * A {@link ListIterator} pointing {@link Pair} of key and value. - */ - private list_iterator_; - /** - * Construct from the {@link MapContainer source map} and {@link ListIterator list iterator}. - * - * @param source The source {@link MapContainer}. - * @param list_iterator A {@link ListIterator} pointing {@link Pair} of key and value. - */ - constructor(source: base.MapContainer, list_iterator: ListIterator>); - /** - * Get iterator to previous element. - */ - prev(): MapIterator; - /** - * Get iterator to next element. - */ - next(): MapIterator; - /** - * Advances the Iterator by n element positions. - * - * @param step Number of element positions to advance. - * @return An advanced Iterator. - */ - advance(step: number): MapIterator; - /** - * @hidden - */ - private map; - /** - * Get ListIterator. - */ - get_list_iterator(): ListIterator>; - /** - * @inheritdoc - */ - value: Pair; - /** - * Get first, key element. - */ - first: Key; - /** - * Get second, value element. - */ - /** - * Set second value. - */ - second: T; - /** - *

Whether an iterator is equal with the iterator.

- * - *

Compare two iterators and returns whether they are equal or not.

- * - * @param obj An iterator to compare - * @return Indicates whether equal or not. - */ - equal_to(obj: MapIterator): boolean; - less(obj: MapIterator): boolean; - hash(): number; - swap(obj: MapIterator): void; - } - /** - *

A reverse-iterator of {@link MapContainer map container}.

- * - *

- *

- * - * @author Jeongho Nam - */ - class MapReverseIterator extends ReverseIterator, MapIterator, MapReverseIterator> { - /** - * Construct from base iterator. - * - * @param base A reference of the base iterator, which iterates in the opposite direction. - */ - constructor(base: MapIterator); - /** - * @hidden - */ - protected create_neighbor(base: MapIterator): MapReverseIterator; - /** - * Get first, key element. - */ - first: Key; - /** - * Get second, value element. - */ - /** - * Set second value. - */ - second: T; - } -} -declare namespace std.base { - /** - *

An abstract unique-map.

- * - *

{@link UniqueMap UniqueMaps} are associative containers that store elements formed by a combination of a - * key value (Key) and a mapped value (T), and which allows for fast retrieval of - * individual elements based on their keys.

- * - *

In a {@link MapContainer}, the key values are generally used to uniquely identify the elements, - * while the mapped values store the content associated to this key. The types of key and - * mapped value may differ, and are grouped together in member type value_type, which is a - * {@link Pair} type combining both:

- * - *

typedef pair value_type;

- * - *

{@link UniqueMap} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute position - * in the container. - *
- * - *
Map
- *
- * Each element associates a key to a mapped value: - * Keys are meant to identify the elements whose main content is the mapped value. - *
- * - *
Unique keys
- *
No two elements in the container can have equivalent keys.
- *
- * - * @param Type of the keys. Each element in a map is uniquely identified by its key value. - * @param Type of the mapped value. Each element in a map stores some data as its mapped value. - * - * @author Jeongho Nam - */ - abstract class UniqueMap extends MapContainer { - /** - * @inheritdoc - */ - count(key: Key): number; - /** - *

Get an element

- * - *

Returns a reference to the mapped value of the element identified with key.

- * - * @param key Key value of the element whose mapped value is accessed. - * - * @throw exception out of range - * - * @return A reference object of the mapped value (_Ty) - */ - get(key: Key): T; - /** - *

Set an item as the specified identifier.

- * - *

If the identifier is already in map, change value of the identifier. If not, then insert the object - * with the identifier.

- * - * @param key Key value of the element whose mapped value is accessed. - * @param val Value, the item. - */ - set(key: Key, val: T): void; - /** - *

Extract an element.

- * - *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

- * - * @param key Key value of the element whose mapped value is accessed. - * - * @return A {@link Pair} containing the value pointed to by key. - */ - extract(key: Key): Pair; - /** - *

Extract an element.

- * - *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

- * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: MapIterator): MapIterator; - /** - *

Extract an element.

- * - *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

- * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: MapReverseIterator): MapReverseIterator; - /** - * @hidden - */ - private extract_by_key(key); - /** - * @hidden - */ - private extract_by_iterator(it); - /** - * @hidden - */ - private extract_by_reverse_iterator(it); - /** - *

Insert an element.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} by - * one.

- * - *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether - * each inserted element has a key equivalent to the one of an element already in the container, and - * if so, the element is not inserted, returning an iterator to this existing element (if the function - * returns a value).

- * - *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

- * - * @param pair {@link Pair} to be inserted as an element. - * - * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly - * inserted element or to the element with an equivalent key in the {@link UniqueMap}. The - * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or - * false if an equivalent key already existed. - */ - insert(pair: Pair): Pair, boolean>; - /** - *

Insert an element.

- * - *

Extends the container by inserting a new element, effectively increasing the container size by the - * number of elements inserted.

- * - *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether - * each inserted element has a key equivalent to the one of an element already in the container, and - * if so, the element is not inserted, returning an iterator to this existing element (if the function - * returns a value).

- * - *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

- * - * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. - * - * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly - * inserted element or to the element with an equivalent key in the {@link UniqueMap}. The - * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or - * false if an equivalent key already existed. - */ - insert(tuple: [L, U]): Pair, boolean>; - /** - * @inheritdoc - */ - insert(hint: MapIterator, pair: Pair): MapIterator; - /** - * @inheritdoc - */ - insert(hint: MapReverseIterator, pair: Pair): MapReverseIterator; - /** - * @inheritdoc - */ - insert(hint: MapIterator, tuple: [L, U]): MapIterator; - /** - * @inheritdoc - */ - insert(hint: MapReverseIterator, tuple: [L, U]): MapReverseIterator; - /** - * @inheritdoc - */ - insert>>(first: InputIterator, last: InputIterator): void; - /** - *

Insert or assign an element.

- * - *

Inserts an element or assigns to the current element if the key already exists.

- * - *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether - * each inserted element has a key equivalent to the one of an element already in the container, and - * if so, the element is assigned, returning an iterator to this existing element (if the function returns a - * value).

- * - *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

- * - * @param key The key used both to look up and to insert if not found. - * @param value Value, the item. - * - * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly - * inserted element or to the element with an equivalent key in the {@link UniqueMap}. The - * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or - * false if an equivalent key already existed so the value is assigned. - */ - insert_or_assign(key: Key, value: T): Pair, boolean>; - /** - *

Insert or assign an element.

- * - *

Inserts an element or assigns to the current element if the key already exists.

- * - *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether - * each inserted element has a key equivalent to the one of an element already in the container, and - * if so, the element is assigned, returning an iterator to this existing element (if the function returns a - * value).

- * - *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

- * - * @param hint Hint for the position where the element can be inserted. - * @param key The key used both to look up and to insert if not found. - * @param value Value, the item. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had an - * equivalent key in the {@link UniqueMap}. - */ - insert_or_assign(hint: MapIterator, key: Key, value: T): MapIterator; - /** - *

Insert or assign an element.

- * - *

Inserts an element or assigns to the current element if the key already exists.

- * - *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether - * each inserted element has a key equivalent to the one of an element already in the container, and - * if so, the element is assigned, returning an iterator to this existing element (if the function returns a - * value).

- * - *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

- * - * @param hint Hint for the position where the element can be inserted. - * @param key The key used both to look up and to insert if not found. - * @param value Value, the item. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had an - * equivalent key in the {@link UniqueMap}. - */ - insert_or_assign(hint: MapReverseIterator, key: Key, value: T): MapReverseIterator; - /** - * @hidden - */ - private insert_or_assign_with_key_value(key, value); - /** - * @hidden - */ - private insert_or_assign_with_hint(hint, key, value); - } -} -declare namespace std.base { - /** - *

An abstract multi-map.

- * - *

{@link MultiMap MultiMaps} are associative containers that store elements formed by a combination of a - * key value (Key) and a mapped value (T), and which allows for fast retrieval of - * individual elements based on their keys.

- * - *

In a {@link MapContainer}, the key values are generally used to identify the elements, while the - * mapped values store the content associated to this key. The types of key and - * mapped value may differ, and are grouped together in member type value_type, which is a - * {@link Pair} type combining both:

- * - *

typedef pair value_type;

- * - *

{@link UniqueMap} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute position - * in the container. - *
- * - *
Map
- *
- * Each element associates a key to a mapped value: - * Keys are meant to identify the elements whose main content is the mapped value. - *
- * - *
Multiple equivalent keys
- *
Multiple elements in the container can have equivalent keys.
- *
- * - * @param Type of the keys. Each element in a map is identified by its key value. - * @param Type of the mapped value. Each element in a map stores some data as its mapped value. - * - * @author Jeongho Nam - */ - abstract class MultiMap extends MapContainer { - /** - *

Insert elements.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} by - * the number of elements inserted.

- * - * @param pair {@link Pair} to be inserted as an element. - * - * @return An iterator pointing to the newly inserted element. - */ - insert(pair: Pair): MapIterator; - /** - *

Insert elements.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} by - * the number of elements inserted.

- * - * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. - * - * @return An iterator pointing to the newly inserted element. - */ - insert(tuple: [L, U]): MapIterator; - /** - * @inheritdoc - */ - insert(hint: MapIterator, pair: Pair): MapIterator; - /** - * @inheritdoc - */ - insert(hint: MapReverseIterator, pair: Pair): MapReverseIterator; - /** - * @inheritdoc - */ - insert(hint: MapIterator, tuple: [L, U]): MapIterator; - /** - * @inheritdoc - */ - insert(hint: MapReverseIterator, tuple: [L, U]): MapReverseIterator; - /** - * @inheritdoc - */ - insert>>(first: InputIterator, last: InputIterator): void; - } -} -declare namespace std.HashMap { - type iterator = std.MapIterator; - type reverse_iterator = std.MapReverseIterator; -} -declare namespace std { - /** - *

Hashed, unordered map.

- * - *

{@link HashMap}s are associative containers that store elements formed by the combination of a key value - * and a mapped value, and which allows for fast retrieval of individual elements based on their keys. - *

- * - *

In an {@link HashMap}, the key value is generally used to uniquely identify the element, while the - * mapped value is an object with the content associated to this key. Types of key and - * mapped value may differ.

- * - *

Internally, the elements in the {@link HashMap} are not sorted in any particular order with respect to either - * their key or mapped values, but organized into buckets depending on their hash values to allow - * for fast access to individual elements directly by their key values (with a constant average time complexity - * on average).

- * - *

{@link HashMap} containers are faster than {@link TreeMap} containers to access individual elements by their - * key, although they are generally less efficient for range iteration through a subset of their elements.

- * - *

- * - *

- * - *

Container properties

- *
- *
Associative
- *
Elements in associative containers are referenced by their key and not by their absolute - * position in the container.
- * - *
Hashed
- *
Hashed containers organize their elements using hash tables that allow for fast access to elements - * by their key.
- * - *
Map
- *
Each element associates a key to a mapped value: - * Keys are meant to identify the elements whose main content is the mapped value.
- * - *
Unique keys
- *
No two elements in the container can have equivalent keys.
- *
- * - * @param Type of the key values. - * Each element in an {@link HashMap} is uniquely identified by its key value. - * @param Type of the mapped value. - * Each element in an {@link HashMap} is used to store some data as its mapped value. - * - * @reference http://www.cplusplus.com/reference/unordered_map/unordered_map - * @author Jeongho Nam - */ - class HashMap extends base.UniqueMap implements base.IHashMap { - /** - * @hidden - */ - private hash_buckets_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from elements. - */ - constructor(items: Pair[]); - /** - * Contruct from tuples. - * - * @param array Tuples to be contained. - */ - constructor(array: [Key, T][]); - /** - * Copy Constructor. - */ - constructor(container: HashMap); - /** - * Construct from range iterators. - */ - constructor(begin: Iterator>, end: Iterator>); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: Key): MapIterator; - /** - * @inheritdoc - */ - begin(): MapIterator; - /** - * @inheritdoc - */ - begin(index: number): MapIterator; - /** - * @inheritdoc - */ - end(): MapIterator; - /** - * @inheritdoc - */ - end(index: number): MapIterator; - /** - * @inheritdoc - */ - rbegin(): MapReverseIterator; - /** - * @inheritdoc - */ - rbegin(index: number): MapReverseIterator; - /** - * @inheritdoc - */ - rend(): MapReverseIterator; - /** - * @inheritdoc - */ - rend(index: number): MapReverseIterator; - /** - * @inheritdoc - */ - bucket_count(): number; - /** - * @inheritdoc - */ - bucket_size(index: number): number; - /** - * @inheritdoc - */ - max_load_factor(): number; - /** - * @inheritdoc - */ - max_load_factor(z: number): void; - /** - * @inheritdoc - */ - bucket(key: Key): number; - /** - * @inheritdoc - */ - reserve(n: number): void; - /** - * @inheritdoc - */ - rehash(n: number): void; - /** - * @hidden - */ - protected _Insert_by_pair(pair: Pair): any; - /** - * @hidden - */ - protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; - /** - * @hidden - */ - protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: MapIterator, last: MapIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: MapIterator, last: MapIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link HashMap map} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link HashMap map container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link HashMap container}. - */ - swap(obj: HashMap): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer>): void; - } -} -declare namespace std.HashMultiMap { - type iterator = std.MapIterator; - type reverse_iterator = std.MapReverseIterator; -} -declare namespace std { - /** - *

Hashed, unordered Multimap.

- * - *

{@link HashMultiMap}s are associative containers that store elements formed by the combination of - * a key value and a mapped value, much like {@link HashMultiMap} containers, but allowing - * different elements to have equivalent keys.

- * - *

In an {@link HashMultiMap}, the key value is generally used to uniquely identify the - * element, while the mapped value is an object with the content associated to this key. - * Types of key and mapped value may differ.

- * - *

Internally, the elements in the {@link HashMultiMap} are not sorted in any particular order with - * respect to either their key or mapped values, but organized into buckets depending on - * their hash values to allow for fast access to individual elements directly by their key values - * (with a constant average time complexity on average).

- * - *

Elements with equivalent keys are grouped together in the same bucket and in such a way that - * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

- * - *

- * - *

- * - *

Container properties

- *
- *
Associative
- *
Elements in associative containers are referenced by their key and not by their absolute - * position in the container.
- * - *
Hashed
- *
Hashed containers organize their elements using hash tables that allow for fast access to elements - * by their key.
- * - *
Map
- *
Each element associates a key to a mapped value: - * Keys are meant to identify the elements whose main content is the mapped value.
- * - *
Multiple equivalent keys
- *
The container can hold multiple elements with equivalent keys.
- *
- * - * @param Type of the key values. - * Each element in an {@link HashMultiMap} is identified by a key value. - * @param Type of the mapped value. - * Each element in an {@link HashMultiMap} is used to store some data as its mapped value. - * - * @reference http://www.cplusplus.com/reference/unordered_map/unordered_multimap - * @author Jeongho Nam - */ - class HashMultiMap extends base.MultiMap { - /** - * @hidden - */ - private hash_buckets_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from elements. - */ - constructor(items: Pair[]); - /** - * Contruct from tuples. - * - * @param array Tuples to be contained. - */ - constructor(array: [Key, T][]); - /** - * Copy Constructor. - */ - constructor(container: HashMultiMap); - /** - * Construct from range iterators. - */ - constructor(begin: Iterator>, end: Iterator>); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: Key): MapIterator; - /** - * @inheritdoc - */ - count(key: Key): number; - /** - * @inheritdoc - */ - begin(): MapIterator; - /** - * @inheritdoc - */ - begin(index: number): MapIterator; - /** - * @inheritdoc - */ - end(): MapIterator; - /** - * @inheritdoc - */ - end(index: number): MapIterator; - /** - * @inheritdoc - */ - rbegin(): MapReverseIterator; - /** - * @inheritdoc - */ - rbegin(index: number): MapReverseIterator; - /** - * @inheritdoc - */ - rend(): MapReverseIterator; - /** - * @inheritdoc - */ - rend(index: number): MapReverseIterator; - /** - * @inheritdoc - */ - bucket_count(): number; - /** - * @inheritdoc - */ - bucket_size(n: number): number; - /** - * @inheritdoc - */ - max_load_factor(): number; - /** - * @inheritdoc - */ - max_load_factor(z: number): void; - /** - * @inheritdoc - */ - bucket(key: Key): number; - /** - * @inheritdoc - */ - reserve(n: number): void; - /** - * @inheritdoc - */ - rehash(n: number): void; - /** - * @hidden - */ - protected _Insert_by_pair(pair: Pair): any; - /** - * @hidden - */ - protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; - /** - * @hidden - */ - protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: MapIterator, last: MapIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: MapIterator, last: MapIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link HashMultiMap map} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link HashMultiMap map container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link HashMultiMap container}. - */ - swap(obj: HashMultiMap): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer>): void; - } -} -declare namespace std.base { - /** - *

An abstract set.

- * - *

{@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of - * individual elements based on their value.

- * - *

In an {@link SetContainer}, the value of an element is at the same time its key, used to - * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be - * modified once in the container - they can be inserted and removed, though.

- * - *

{@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
- * - *
Set
- *
The value of an element is also the key used to identify it.
- *
- * - * @param Type of the elements. Each element in a {@link SetContainer} container is also identified - * by this value (each value is itself also the element's key). - * - * @author Jeongho Nam - */ - abstract class SetContainer extends Container { - /** - *

{@link List} storing elements.

- * - *

Storing elements and keeping those sequence of the {@link SetContainer} are implemented by - * {@link data_ this list container}. Implementing index-table is also related with {@link data_ this list} - * by storing {@link ListIterator iterators} ({@link SetIterator} references {@link ListIterator}) who are - * created from {@link data_ here}.

- */ - private data_; - /** - * Default Constructor. - */ - constructor(); - /** - * @inheritdoc - */ - assign>(begin: Iterator, end: Iterator): void; - /** - * @inheritdoc - */ - clear(): void; - /** - *

Get iterator to element.

- * - *

Searches the container for an element with key as value and returns an iterator to it if found, - * otherwise it returns an iterator to {@link end end()} (the element past the end of the container).

- * - *

Another member function, {@link count count()}, can be used to just check whether a particular element - * exists.

- * - * @param key Key to be searched for. - * - * @return An iterator to the element, if the specified value is found, or {@link end end()} if it is not - * found in the - */ - abstract find(val: T): SetIterator; - /** - * @inheritdoc - */ - begin(): SetIterator; - /** - * @inheritdoc - */ - end(): SetIterator; - /** - * @inheritdoc - */ - rbegin(): SetReverseIterator; - /** - * @inheritdoc - */ - rend(): SetReverseIterator; - /** - *

Whether have the item or not.

- * - *

Indicates whether a set has an item having the specified identifier.

- * - * @param key Key value of the element whose mapped value is accessed. - * - * @return Whether the set has an item having the specified identifier. - */ - has(val: T): boolean; - /** - *

Count elements with a specific key.

- * - *

Searches the container for elements with a value of k and returns the number of elements found.

- * - * @param key Value of the elements to be counted. - * - * @return The number of elements in the container with a key. - */ - abstract count(val: T): number; - /** - * @inheritdoc - */ - size(): number; - /** - * @hidden - */ - _Get_data(): List; - /** - * @inheritdoc - */ - push(...args: U[]): number; - /** - *

Insert an element with hint.

- * - *

Extends the container by inserting new elements, effectively increasing the container size by the - * number of elements inserted.

- * - * @param hint Hint for the position where the element can be inserted. - * @param val Value to be inserted as an element. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had its - * same value in the {@link SetContainer}. - */ - insert(hint: SetIterator, val: T): SetIterator; - /** - *

Insert an element with hint.

- * - *

Extends the container by inserting new elements, effectively increasing the container size by the - * number of elements inserted.

- * - * @param hint Hint for the position where the element can be inserted. - * @param val Value to be inserted as an element. - * - * @return An iterator pointing to either the newly inserted element or to the element that already had its - * same value in the {@link SetContainer}. - */ - insert(hint: SetReverseIterator, val: T): SetReverseIterator; - /** - *

Insert elements with a range of a

- * - *

Extends the container by inserting new elements, effectively increasing the container size by the - * number of elements inserted.

- * - * @param begin An iterator specifying range of the begining element. - * @param end An iterator specifying range of the ending element. - */ - insert>(begin: InputIterator, end: InputIterator): void; - /** - * @hidden - */ - protected abstract _Insert_by_val(val: T): any; - /** - * @hidden - */ - protected abstract _Insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected abstract _Insert_by_range>(begin: InputIterator, end: InputIterator): void; - /** - *

Erase an element.

- *

Removes from the set container the elements whose value is key.

- * - *

This effectively reduces the container size by the number of elements removed.

- * - * @param key Value of the elements to be erased. - * - * @return Number of elements erased. - */ - erase(val: T): number; - /** - * @inheritdoc - */ - erase(it: SetIterator): SetIterator; - /** - *

Erase elements.

- *

Removes from the set container a range of elements..

- * - *

This effectively reduces the container size by the number of elements removed.

- * - * @param begin An iterator specifying a range of beginning to erase. - * @param end An iterator specifying a range of end to erase. - */ - erase(begin: SetIterator, end: SetIterator): SetIterator; - /** - * @inheritdoc - */ - erase(it: SetReverseIterator): SetReverseIterator; - /** - *

Erase elements.

- *

Removes from the set container a range of elements..

- * - *

This effectively reduces the container size by the number of elements removed.

- * - * @param begin An iterator specifying a range of beginning to erase. - * @param end An iterator specifying a range of end to erase. - */ - erase(begin: SetReverseIterator, end: SetReverseIterator): SetReverseIterator; - /** - * @hidden - */ - private erase_by_iterator(first, last?); - /** - * @hidden - */ - private erase_by_val(val); - /** - * @hidden - */ - private erase_by_range(begin, end); - /** - *

Abstract method handling insertions for indexing.

- * - *

This method, {@link handle_insert} is designed to register the first to last to somewhere storing - * those {@link SetIterator iterators} for indexing, fast accessment and retrievalance.

- * - *

When {@link insert} is called, new elements will be inserted into the {@link data_ list container} and new - * {@link SetIterator iterators} first to last, pointing the inserted elements, will be created and the - * newly created iterators first to last will be shifted into this method {@link handle_insert} after the - * insertions.

- * - *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link SetIterator iterators} - * will be registered into the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the - * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be - * registered into the {@link HashSet.hash_buckets_ hash bucket}.

- * - * @param first An {@link SetIterator} to the initial position in a sequence. - * @param last An {@link SetIterator} to the final position in a sequence. The range used is - * [first, last), which contains all the elements between first and last, - * including the element pointed by first but not the element pointed by last. - */ - protected abstract _Handle_insert(first: SetIterator, last: SetIterator): void; - /** - *

Abstract method handling deletions for indexing.

- * - *

This method, {@link handle_insert} is designed to unregister the first to last to somewhere storing - * those {@link SetIterator iterators} for indexing, fast accessment and retrievalance.

- * - *

When {@link erase} is called with first to last, {@link SetIterator iterators} positioning somewhere - * place to be deleted, is memorized and shifted to this method {@link handle_erase} after the deletion process is - * terminated.

- * - *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link SetIterator iterators} - * will be unregistered from the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the - * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be - * unregistered from the {@link HashSet.hash_buckets_ hash bucket}.

- * - * @param first An {@link SetIterator} to the initial position in a sequence. - * @param last An {@link SetIterator} to the final position in a sequence. The range used is - * [first, last), which contains all the elements between first and last, - * including the element pointed by first but not the element pointed by last. - */ - protected abstract _Handle_erase(first: SetIterator, last: SetIterator): void; - /** - * @hidden - */ - protected _Swap(obj: SetContainer): void; - } -} -declare namespace std { - /** - *

An iterator of a Set.

- * - *

- *

- * - * @author Jeongho Nam - */ - class SetIterator extends Iterator implements IComparable> { - private list_iterator_; - /** - *

Construct from source and index number.

- * - *

Note

- *

Do not create iterator directly.

- *

Use begin(), find() or end() in Map instead.

- * - * @param map The source Set to reference. - * @param index Sequence number of the element in the source Set. - */ - constructor(source: base.SetContainer, it: ListIterator); - /** - * @inheritdoc - */ - prev(): SetIterator; - /** - * @inheritdoc - */ - next(): SetIterator; - /** - * @inheritdoc - */ - advance(size: number): SetIterator; - /** - * @hidden - */ - private set; - get_list_iterator(): ListIterator; - /** - * @inheritdoc - */ - value: T; - /** - * @inheritdoc - */ - equal_to(obj: SetIterator): boolean; - /** - * @inheritdoc - */ - less(obj: SetIterator): boolean; - /** - * @inheritdoc - */ - hash(): number; - /** - * @inheritdoc - */ - swap(obj: SetIterator): void; - } - /** - *

A reverse-iterator of Set.

- * - *

- *

- * - * @param Type of the elements. - * - * @author Jeongho Nam - */ - class SetReverseIterator extends ReverseIterator, SetReverseIterator> { - /** - * Construct from base iterator. - * - * @param base A reference of the base iterator, which iterates in the opposite direction. - */ - constructor(base: SetIterator); - /** - * @hidden - */ - protected create_neighbor(base: SetIterator): SetReverseIterator; - } -} -declare namespace std.base { - /** - *

An abstract set.

- * - *

{@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of - * individual elements based on their value.

- * - *

In an {@link SetContainer}, the value of an element is at the same time its key, used to - * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be - * modified once in the container - they can be inserted and removed, though.

- * - *

{@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
- * - *
Set
- *
The value of an element is also the key used to identify it.
- * - *
Multiple equivalent keys
- *
Multiple elements in the container can have equivalent keys.
- *
- * - * @param Type of the elements. Each element in a {@link SetContainer} container is also identified - * by this value (each value is itself also the element's key). - * - * @author Jeongho Nam - */ - abstract class MultiSet extends SetContainer { - /** - *

Insert an element.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} by - * the number of elements inserted.

- * - * @param key Value to be inserted as an element. - * - * @return An iterator to the newly inserted element. - */ - insert(val: T): SetIterator; - /** - * @inheritdoc - */ - insert(hint: SetIterator, val: T): SetIterator; - /** - * @inheritdoc - */ - insert(hint: SetReverseIterator, val: T): SetReverseIterator; - /** - * @inheritdoc - */ - insert>(begin: InputIterator, end: InputIterator): void; - } -} -declare namespace std.HashMultiSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

Hashed, unordered Multiset.

- * - *

{@link HashMultiSet HashMultiSets} are containers that store elements in no particular order, allowing fast - * retrieval of individual elements based on their value, much like {@link HashMultiSet} containers, - * but allowing different elements to have equivalent values.

- * - *

In an {@link HashMultiSet}, the value of an element is at the same time its key, used to - * identify it. Keys are immutable, therefore, the elements in an {@link HashMultiSet} cannot be - * modified once in the container - they can be inserted and removed, though.

- * - *

Internally, the elements in the {@link HashMultiSet} are not sorted in any particular, but - * organized into buckets depending on their hash values to allow for fast access to individual - * elements directly by their values (with a constant average time complexity on average).

- * - *

Elements with equivalent values are grouped together in the same bucket and in such a way that an - * iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
Elements in associative containers are referenced by their key and not by their absolute - * position in the container.
- * - *
Hashed
- *
Hashed containers organize their elements using hash tables that allow for fast access to elements - * by their key.
- * - *
Set
- *
The value of an element is also the key used to identify it.
- * - *
Multiple equivalent keys
- *
The container can hold multiple elements with equivalent keys.
- *
- * - * @param Type of the elements. - * Each element in an {@link UnorderedMultiSet} is also identified by this value.. - * - * @reference http://www.cplusplus.com/reference/unordered_set/unordered_multiset - * @author Jeongho Nam - */ - class HashMultiSet extends base.MultiSet { - /** - * @hidden - */ - private hash_buckets_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from elements. - */ - constructor(items: T[]); - /** - * Copy Constructor. - */ - constructor(container: HashMultiSet); - /** - * Construct from range iterators. - */ - constructor(begin: Iterator, end: Iterator); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: T): SetIterator; - /** - * @inheritdoc - */ - count(key: T): number; - /** - * @inheritdoc - */ - begin(): SetIterator; - /** - * @inheritdoc - */ - begin(index: number): SetIterator; - /** - * @inheritdoc - */ - end(): SetIterator; - /** - * @inheritdoc - */ - end(index: number): SetIterator; - /** - * @inheritdoc - */ - rbegin(): SetReverseIterator; - /** - * @inheritdoc - */ - rbegin(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - rend(): SetReverseIterator; - /** - * @inheritdoc - */ - rend(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - bucket_count(): number; - /** - * @inheritdoc - */ - bucket_size(n: number): number; - /** - * @inheritdoc - */ - max_load_factor(): number; - /** - * @inheritdoc - */ - max_load_factor(z: number): void; - /** - * @inheritdoc - */ - bucket(key: T): number; - /** - * @inheritdoc - */ - reserve(n: number): void; - /** - * @inheritdoc - */ - rehash(n: number): void; - /** - * @hidden - */ - protected _Insert_by_val(val: T): any; - /** - * @hidden - */ - protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: SetIterator, last: SetIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link HashMultiSet set} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link HashMultiSet set container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link HashMultiSet container}. - */ - swap(obj: HashMultiSet): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } -} -declare namespace std.base { - /** - *

An abstract set.

- * - *

{@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of - * individual elements based on their value.

- * - *

In an {@link SetContainer}, the value of an element is at the same time its key, used to uniquely - * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be modified - * once in the container - they can be inserted and removed, though.

- * - *

{@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a - * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index - * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
- * - *
Set
- *
The value of an element is also the key used to identify it.
- * - *
Unique keys
- *
No two elements in the container can have equivalent keys.
- *
- * - * @param Type of the elements. Each element in a {@link SetContainer} container is also identified - * by this value (each value is itself also the element's key). - * - * @author Jeongho Nam - */ - abstract class UniqueSet extends SetContainer { - /** - * @inheritdoc - */ - count(key: T): number; - /** - *

Extract an element.

- * - *

Extracts the element pointed to by val and erases it from the {@link UniqueSet}.

- * - * @param val Value to be extracted. - * - * @return A value. - */ - extract(val: T): T; - /** - *

Extract an element.

- * - *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

- * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: SetIterator): SetIterator; - /** - *

Extract an element.

- * - *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

- * - * @param it An iterator pointing an element to extract. - * - * @return An iterator pointing to the element immediately following it prior to the element being - * erased. If no such element exists,returns {@link end end()}. - */ - extract(it: SetReverseIterator): SetReverseIterator; - /** - * @hidden - */ - private extract_by_key(val); - /** - * @hidden - */ - private extract_by_iterator(it); - /** - * @hidden - */ - private extract_by_reverse_iterator(it); - /** - *

Insert an element.

- * - *

Extends the container by inserting new elements, effectively increasing the container {@link size} by - * the number of element inserted (zero or one).

- * - *

Because elements in a {@link UniqueSet UniqueSets} are unique, the insertion operation checks whether - * each inserted element is equivalent to an element already in the container, and if so, the element is not - * inserted, returning an iterator to this existing element (if the function returns a value).

- * - *

For a similar container allowing for duplicate elements, see {@link MultiSet}.

- * - * @param key Value to be inserted as an element. - * - * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly - * inserted element or to the equivalent element already in the {@link UniqueSet}. The - * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or - * false if an equivalent element already existed. - */ - insert(val: T): Pair, boolean>; - /** - * @inheritdoc - */ - insert(hint: SetIterator, val: T): SetIterator; - /** - * @inheritdoc - */ - insert(hint: SetReverseIterator, val: T): SetReverseIterator; - /** - * @inheritdoc - */ - insert>(begin: InputIterator, end: InputIterator): void; - } -} -declare namespace std.HashSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

Hashed, unordered set.

- * - *

{@link HashSet}s are containers that store unique elements in no particular order, and which - * allow for fast retrieval of individual elements based on their value.

- * - *

In an {@link HashSet}, the value of an element is at the same time its key, that - * identifies it uniquely. Keys are immutable, therefore, the elements in an {@link HashSet} cannot be - * modified once in the container - they can be inserted and removed, though.

- * - *

Internally, the elements in the {@link HashSet} are not sorted in any particular order, but - * organized into buckets depending on their hash values to allow for fast access to individual elements - * directly by their values (with a constant average time complexity on average).

- * - *

{@link HashSet} containers are faster than {@link TreeSet} containers to access individual - * elements by their key, although they are generally less efficient for range iteration through a - * subset of their elements.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
Elements in associative containers are referenced by their key and not by their absolute - * position in the container.
- * - *
Hashed
- *
Hashed containers organize their elements using hash tables that allow for fast access to elements - * by their key.
- * - *
Set
- *
The value of an element is also the key used to identify it.
- * - *
Unique keys
- *
No two elements in the container can have equivalent keys.
- *
- * - * @param Type of the elements. - * Each element in an {@link HashSet} is also uniquely identified by this value. - * - * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set - * @author Jeongho Nam - */ - class HashSet extends base.UniqueSet implements base.IHashSet { - /** - * @hidden - */ - private hash_buckets_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from elements. - */ - constructor(items: T[]); - /** - * Copy Constructor. - */ - constructor(container: HashSet); - /** - * Construct from range iterators. - */ - constructor(begin: Iterator, end: Iterator); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: T): SetIterator; - /** - * @inheritdoc - */ - begin(): SetIterator; - /** - * @inheritdoc - */ - begin(index: number): SetIterator; - /** - * @inheritdoc - */ - end(): SetIterator; - /** - * @inheritdoc - */ - end(index: number): SetIterator; - /** - * @inheritdoc - */ - rbegin(): SetReverseIterator; - /** - * @inheritdoc - */ - rbegin(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - rend(): SetReverseIterator; - /** - * @inheritdoc - */ - rend(index: number): SetReverseIterator; - /** - * @inheritdoc - */ - bucket_count(): number; - /** - * @inheritdoc - */ - bucket_size(n: number): number; - /** - * @inheritdoc - */ - max_load_factor(): number; - /** - * @inheritdoc - */ - max_load_factor(z: number): void; - /** - * @inheritdoc - */ - bucket(key: T): number; - /** - * @inheritdoc - */ - reserve(n: number): void; - /** - * @inheritdoc - */ - rehash(n: number): void; - /** - * @hidden - */ - protected _Insert_by_val(val: T): any; - /** - * @hidden - */ - protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: SetIterator, last: SetIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link HashSet set} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link HashSet set container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link HashSet container}. - */ - swap(obj: HashSet): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } -} -declare namespace std.List { - type iterator = std.ListIterator; - type reverse_iterator = std.ListReverseIterator; -} -declare namespace std { - /** - *

Doubly linked list.

- * - *

{@link List}s are sequence containers that allow constant time insert and erase operations anywhere within the - * sequence, and iteration in both directions.

- * - *

List containers are implemented as doubly-linked lists; Doubly linked lists can store each of the elements they - * contain in different and unrelated storage locations. The ordering is kept internally by the association to each - * element of a link to the element preceding it and a link to the element following it.

- * - *

They are very similar to forward_list: The main difference being that forward_list objects are single-linked - * lists, and thus they can only be iterated forwards, in exchange for being somewhat smaller and more efficient.

- * - *

Compared to other base standard sequence containers (array, vector and deque), lists perform generally better - * in inserting, extracting and moving elements in any position within the container for which an iterator has already - * been obtained, and therefore also in algorithms that make intensive use of these, like sorting algorithms.

- * - *

The main drawback of lists and forward_lists compared to these other sequence containers is that they lack - * direct access to the elements by their position; For example, to access the sixth element in a list, one has to - * iterate from a known position (like the beginning or the end) to that position, which takes linear time in the - * distance between these. They also consume some extra memory to keep the linking information associated to each - * element (which may be an important factor for large lists of small-sized elements).

- * - *

- * - *

- * - *

Container properties

- *
- *
Sequence
- *
Elements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by - * their position in this sequence.
- * - *
Doubly-linked list
- *
Each element keeps information on how to locate the next and the previous elements, allowing constant time - * insert and erase operations before or after a specific element (even of entire ranges), but no direct random - * access.
- *
- * - * @param Type of the elements. - * - * @reference http://www.cplusplus.com/reference/list/list/ - * @author Jeongho Nam - */ - class List extends base.Container implements base.IDequeContainer { - /** - * @hidden - */ - private begin_; - /** - * @hidden - */ - private end_; - /** - * @hidden - */ - private size_; - /** - *

Default Constructor.

- * - *

Constructs an empty container, with no elements.

- */ - constructor(); - /** - *

Initializer list Constructor.

- * - *

Constructs a container with a copy of each of the elements in array, in the same order.

- * - * @param array An array containing elements to be copied and contained. - */ - constructor(items: Array); - /** - *

Fill Constructor.

- * - *

Constructs a container with n elements. Each element is a copy of val (if provided).

- * - * @param n Initial container size (i.e., the number of elements in the container at construction). - * @param val Value to fill the container with. Each of the n elements in the container is - * initialized to a copy of this value. - */ - constructor(size: number, val: T); - /** - *

Copy Constructor.

- * - *

Constructs a container with a copy of each of the elements in container, in the same order.

- * - * @param container Another container object of the same type (with the same class template - * arguments T), whose contents are either copied or acquired. - */ - constructor(container: List); - /** - *

Range Constructor.

- * - *

Constructs a container with as many elements as the range (begin, end), with each - * element emplace-constructed from its corresponding element in that range, in the same order.

- * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * @inheritdoc - */ - assign(n: number, val: T): void; - /** - * @inheritdoc - */ - assign>(begin: InputIterator, end: InputIterator): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - begin(): ListIterator; - /** - * @inheritdoc - */ - end(): ListIterator; - /** - * @inheritdoc - */ - rbegin(): ListReverseIterator; - /** - * @inheritdoc - */ - rend(): ListReverseIterator; - /** - * @inheritdoc - */ - size(): number; - /** - * @inheritdoc - */ - front(): T; - /** - * @inheritdoc - */ - back(): T; - /** - * @inheritdoc - */ - push(...items: U[]): number; - /** - * @inheritdoc - */ - push_front(val: T): void; - /** - * @inheritdoc - */ - push_back(val: T): void; - /** - * @inheritdoc - */ - pop_front(): void; - /** - * @inheritdoc - */ - pop_back(): void; - /** - *

Insert an element.

- * - *

The container is extended by inserting a new element before the element at the specified - * position. This effectively increases the {@link List.size List size} by the amount of elements - * inserted.

- * - *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient - * inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Position in the container where the new element is inserted. - * {@link iterator}> is a member type, defined as a - * {@link ListIterator bidirectional iterator} type that points to elements. - * @param val Value to be inserted as an element. - * - * @return An iterator that points to the newly inserted element; val. - */ - insert(position: ListIterator, val: T): ListIterator; - /** - *

Insert elements by repeated filling.

- * - *

The container is extended by inserting a new element before the element at the specified - * position. This effectively increases the {@link List.size List size} by the amount of elements - * inserted.

- * - *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient - * inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Position in the container where the new elements are inserted. The {@link iterator} is a - * member type, defined as a {@link ListIterator bidirectional iterator} type that points to - * elements. - * @param size Number of elements to insert. - * @param val Value to be inserted as an element. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert(position: ListIterator, size: number, val: T): ListIterator; - /** - *

Insert elements by range iterators.

- * - *

The container is extended by inserting a new element before the element at the specified - * position. This effectively increases the {@link List.size List size} by the amount of elements - * inserted.

- * - *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient - * inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Position in the container where the new elements are inserted. The {@link iterator} is a - * member type, defined as a {@link ListIterator bidirectional iterator} type that points to - * elements. - * @param begin An iterator specifying range of the begining element. - * @param end An iterator specifying range of the ending element. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert>(position: ListIterator, begin: InputIterator, end: InputIterator): ListIterator; - /** - *

Insert an element.

- * - *

The container is extended by inserting a new element before the element at the specified - * position. This effectively increases the {@link List.size List size} by the amount of elements - * inserted.

- * - *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient - * inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Position in the container where the new element is inserted. - * {@link iterator}> is a member type, defined as a - * {@link ListReverseIterator bidirectional iterator} type that points to elements. - * @param val Value to be inserted as an element. - * - * @return An iterator that points to the newly inserted element; val. - */ - insert(position: ListReverseIterator, val: T): ListReverseIterator; - /** - *

Insert elements by repeated filling.

- * - *

The container is extended by inserting a new element before the element at the specified - * position. This effectively increases the {@link List.size List size} by the amount of elements - * inserted.

- * - *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient - * inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Position in the container where the new elements are inserted. The {@link iterator} is a - * member type, defined as a {@link ListReverseIterator bidirectional iterator} type that points to - * elements. - * @param size Number of elements to insert. - * @param val Value to be inserted as an element. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert(position: ListReverseIterator, size: number, val: T): ListReverseIterator; - /** - *

Insert elements by range iterators.

- * - *

The container is extended by inserting a new element before the element at the specified - * position. This effectively increases the {@link List.size List size} by the amount of elements - * inserted.

- * - *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient - * inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Position in the container where the new elements are inserted. The {@link iterator} is a - * member type, defined as a {@link ListReverseIterator bidirectional iterator} type that points to - * elements. - * @param begin An iterator specifying range of the begining element. - * @param end An iterator specifying range of the ending element. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert>(position: ListReverseIterator, begin: InputIterator, end: InputIterator): ListReverseIterator; - /** - * @hidden - */ - private insert_by_val(position, val); - /** - * @hidden - */ - protected _Insert_by_repeating_val(position: ListIterator, size: number, val: T): ListIterator; - /** - * @hidden - */ - protected _Insert_by_range>(position: ListIterator, begin: InputIterator, end: InputIterator): ListIterator; - /** - *

Erase an element.

- * - *

Removes from the {@link List} either a single element; position.

- * - *

This effectively reduces the container size by the number of element removed.

- * - *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be - * efficient inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Iterator pointing to a single element to be removed from the {@link List}. - * - * @return An iterator pointing to the element that followed the last element erased by the function call. - * This is the {@link end end()} if the operation erased the last element in the sequence. - */ - erase(position: ListIterator): ListIterator; - /** - *

Erase elements.

- * - *

Removes from the {@link List} container a range of elements.

- * - *

This effectively reduces the container {@link size} by the number of elements removed.

- * - *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be - * efficient inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param begin An iterator specifying a range of beginning to erase. - * @param end An iterator specifying a range of end to erase. - * - * @return An iterator pointing to the element that followed the last element erased by the function call. - * This is the {@link end end()} if the operation erased the last element in the sequence. - */ - erase(begin: ListIterator, end: ListIterator): ListIterator; - /** - *

Erase an element.

- * - *

Removes from the {@link List} either a single element; position.

- * - *

This effectively reduces the container size by the number of element removed.

- * - *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be - * efficient inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param position Iterator pointing to a single element to be removed from the {@link List}. - * - * @return An iterator pointing to the element that followed the last element erased by the function call. - * This is the {@link rend rend()} if the operation erased the last element in the sequence. - */ - erase(position: ListReverseIterator): ListReverseIterator; - /** - *

Erase elements.

- * - *

Removes from the {@link List} container a range of elements.

- * - *

This effectively reduces the container {@link size} by the number of elements removed.

- * - *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be - * efficient inserting and removing elements in any position, even in the middle of the sequence.

- * - * @param begin An iterator specifying a range of beginning to erase. - * @param end An iterator specifying a range of end to erase. - * - * @return An iterator pointing to the element that followed the last element erased by the function call. - * This is the {@link rend rend()} if the operation erased the last element in the sequence. - */ - erase(begin: ListReverseIterator, end: ListReverseIterator): ListReverseIterator; - /** - * @hidden - */ - protected _Erase_by_range(first: ListIterator, last: ListIterator): ListIterator; - /** - *

Remove duplicate values.

- * - *

Removes all but the first element from every consecutive group of equal elements in the

- * - *

Notice that an element is only removed from the {@link List} container if it compares equal to the - * element immediately preceding it. Thus, this function is especially useful for sorted lists.

- */ - unique(): void; - /** - *

Remove duplicate values.

- * - *

Removes all but the first element from every consecutive group of equal elements in the

- * - *

The argument binary_pred is a specific comparison function that determine the uniqueness - * of an element. In fact, any behavior can be implemented (and not only an equality comparison), but notice - * that the function will call binary_pred(it.value, it.prev().value) for all pairs of elements - * (where it is an iterator to an element, starting from the second) and remove it - * from the {@link List} if the predicate returns true. - * - *

Notice that an element is only removed from the {@link List} container if it compares equal to the - * element immediately preceding it. Thus, this function is especially useful for sorted lists.

- * - * @param binary_pred Binary predicate that, taking two values of the same type than those contained in the - * {@link List}, returns true to remove the element passed as first argument - * from the container, and false otherwise. This shall be a function pointer - * or a function object. - */ - unique(binary_pred: (left: T, right: T) => boolean): void; - /** - *

Remove elements with specific value.

- * - *

Removes from the container all the elements that compare equal to val. This calls the - * destructor of these objects and reduces the container {@link size} by the number of elements removed.

- * - *

Unlike member function {@link List.erase}, which erases elements by their position (using an - * iterator), this function ({@link List.remove}) removes elements by their value.

- * - *

A similar function, {@link List.remove_if}, exists, which allows for a condition other than an - * equality comparison to determine whether an element is removed.

- * - * @param val Value of the elements to be removed. - */ - remove(val: T): void; - /** - *

Remove elements fulfilling condition.

- * - *

Removes from the container all the elements for which pred returns true. This - * calls the destructor of these objects and reduces the container {@link size} by the number of elements - * removed.

- * - *

The function calls pred(it.value) for each element (where it is an iterator - * to that element). Any of the elements in the list for which this returns true, are removed - * from the

- * - * @param pred Unary predicate that, taking a value of the same type as those contained in the forward_list - * object, returns true for those values to be removed from the container, and - * false for those remaining. This can either be a function pointer or a function - * object. - */ - remove_if(pred: (val: T) => boolean): void; - /** - *

Merge sorted {@link List Lists}.

- * - *

Merges obj into the {@link List} by transferring all of its elements at their respective - * ordered positions into the container (both containers shall already be ordered). - *

- * - *

This effectively removes all the elements in obj (which becomes {@link empty}), and inserts - * them into their ordered position within container (which expands in {@link size} by the number of elements - * transferred). The operation is performed without constructing nor destroying any element: they are - * transferred, no matter whether obj is an lvalue or an rvalue, or whether the value_type supports - * move-construction or not.

- * - *

This function requires that the {@link List} containers have their elements already ordered by value - * ({@link less}) before the call. For an alternative on unordered {@link List Lists}, see - * {@link List.splice}.

- * - *

Assuming such ordering, each element of obj is inserted at the position that corresponds to its - * value according to the strict weak ordering defined by {@link less}. The resulting order of equivalent - * elements is stable (i.e., equivalent elements preserve the relative order they had before the call, and - * existing elements precede those equivalent inserted from obj).

- * - * The function does nothing if this == obj. - * - * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). - * Note that this function modifies obj no matter whether an lvalue or rvalue reference is - * passed. - */ - merge(obj: List): void; - /** - *

Merge sorted {@link List Lists}.

- * - *

Merges obj into the {@link List} by transferring all of its elements at their respective - * ordered positions into the container (both containers shall already be ordered). - *

- * - *

This effectively removes all the elements in obj (which becomes {@link empty}), and inserts - * them into their ordered position within container (which expands in {@link size} by the number of elements - * transferred). The operation is performed without constructing nor destroying any element: they are - * transferred, no matter whether obj is an lvalue or an rvalue, or whether the value_type supports - * move-construction or not.

- * - *

The argument compare is a specific predicate to perform the comparison operation between - * elements. This comparison shall produce a strict weak ordering of the elements (i.e., a consistent - * transitive comparison, without considering its reflexiveness). - * - *

This function requires that the {@link List} containers have their elements already ordered by - * compare before the call. For an alternative on unordered {@link List Lists}, see - * {@link List.splice}.

- * - *

Assuming such ordering, each element of obj is inserted at the position that corresponds to its - * value according to the strict weak ordering defined by compare. The resulting order of equivalent - * elements is stable (i.e., equivalent elements preserve the relative order they had before the call, and - * existing elements precede those equivalent inserted from obj).

- * - * The function does nothing if this == obj. - * - * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). - * Note that this function modifies obj no matter whether an lvalue or rvalue reference is - * passed. - * @param compare Binary predicate that, taking two values of the same type than those contained in the - * {@link list}, returns true if the first argument is considered to go before - * the second in the strict weak ordering it defines, and false otherwise. - * This shall be a function pointer or a function object. - */ - merge(obj: List, compare: (left: T, right: T) => boolean): void; - /** - *

Transfer elements from {@link List} to {@link List}.

- * - *

Transfers elements from obj into the container, inserting them at position.

- * - *

This effectively inserts all elements into the container and removes them from obj, altering - * the sizes of both containers. The operation does not involve the construction or destruction of any - * element. They are transferred, no matter whether obj is an lvalue or an rvalue, or whether the - * value_type supports move-construction or not.

- * - *

This first version (1) transfers all the elements of obj into the

- * - * @param position Position within the container where the elements of obj are inserted. - * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). - */ - splice(position: ListIterator, obj: List): void; - /** - *

Transfer an element from {@link List} to {@link List}.

- * - *

Transfers an element from obj, which is pointed by an {@link ListIterator iterator} it, - * into the container, inserting the element at specified position.

- * - *

This effectively inserts an element into the container and removes it from obj, altering the - * sizes of both containers. The operation does not involve the construction or destruction of any element. - * They are transferred, no matter whether obj is an lvalue or an rvalue, or whether the value_type - * supports move-construction or not.

- * - *

This second version (2) transfers only the element pointed by it from obj into the - *

- * - * @param position Position within the container where the element of obj is inserted. - * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). - * This parameter may be this if position points to an element not actually - * being spliced. - * @param it {@link ListIterator Iterator} to an element in obj. Only this single element is - * transferred. - */ - splice(position: ListIterator, obj: List, it: ListIterator): void; - /** - *

Transfer elements from {@link List} to {@link List}.

- * - *

Transfers elements from obj into the container, inserting them at position.

- * - *

This effectively inserts those elements into the container and removes them from obj, altering - * the sizes of both containers. The operation does not involve the construction or destruction of any - * element. They are transferred, no matter whether obj is an lvalue or an rvalue, or whether the - * value_type supports move-construction or not.

- * - *

This third version (3) transfers the range [begin, end) from obj into the - *

- * - * @param position Position within the container where the elements of obj are inserted. - * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). - * This parameter may be this if position points to an element not actually - * being spliced. - * @param begin {@link ListIterator An Iterator} specifying initial position of a range of elements in - * obj. Transfers the elements in the range [begin, end) to - * position. - * @param end {@link ListIterator An Iterator} specifying final position of a range of elements in - * obj. Transfers the elements in the range [begin, end) to - * position. Notice that the range includes all the elements between begin and - * end, including the element pointed by begin but not the one pointed by end. - */ - splice(position: ListIterator, obj: List, begin: ListIterator, end: ListIterator): void; - /** - *

Sort elements in

- * - *

Sorts the elements in the {@link List}, altering their position within the

- * - *

The sorting is performed by applying an algorithm that uses {@link less}. This comparison shall - * produce a strict weak ordering of the elements (i.e., a consistent transitive comparison, without - * considering its reflexiveness).

- * - *

The resulting order of equivalent elements is stable: i.e., equivalent elements preserve the relative - * order they had before the call.

- * - *

The entire operation does not involve the construction, destruction or copy of any element object. - * Elements are moved within the

- */ - sort(): void; - /** - *

Sort elements in

- * - *

Sorts the elements in the {@link List}, altering their position within the

- * - *

The sorting is performed by applying an algorithm that uses compare. This comparison shall - * produce a strict weak ordering of the elements (i.e., a consistent transitive comparison, without - * considering its reflexiveness).

- * - *

The resulting order of equivalent elements is stable: i.e., equivalent elements preserve the relative - * order they had before the call.

- * - *

The entire operation does not involve the construction, destruction or copy of any element object. - * Elements are moved within the

- * - * @param compare Binary predicate that, taking two values of the same type of those contained in the - * {@link List}, returns true if the first argument goes before the second - * argument in the strict weak ordering it defines, and false otherwise. This - * shall be a function pointer or a function object. - */ - sort(compare: (left: T, right: T) => boolean): void; - /** - * @hidden - */ - private qsort(first, last, compare); - /** - * @hidden - */ - private partition(first, last, compare); - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link List container} object with same type of elements. Sizes and container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were in obj - * before the call, and the elements of obj are those which were in this. All iterators, references and - * pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link List container} of the same type of elements (i.e., instantiated - * with the same template parameter, T) whose content is swapped with that of this - * {@link container List}. - */ - swap(obj: List): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } -} -declare namespace std { - /** - *

An iterator, node of a List.

- * - *

- * - *

- * - * @author Jeongho Nam - */ - class ListIterator extends Iterator { - private prev_; - private next_; - private value_; - /** - *

Construct from the source {@link List container}.

- * - *

Note

- *

Do not create the iterator directly, by yourself.

- *

Use {@link List.begin begin()}, {@link List.end end()} in {@link List container} instead.

- * - * @param source The source {@link List container} to reference. - * @param prev A refenrece of previous node ({@link ListIterator iterator}). - * @param next A refenrece of next node ({@link ListIterator iterator}). - * @param value Value to be stored in the node (iterator). - */ - constructor(source: List, prev: ListIterator, next: ListIterator, value: T); - private list(); - /** - * @inheritdoc - */ - prev(): ListIterator; - /** - * @inheritdoc - */ - next(): ListIterator; - /** - * @inheritdoc - */ - advance(step: number): ListIterator; - /** - * @inheritdoc - */ - /** - * Set value of the iterator is pointing to. - * - * @param val Value to set. - */ - value: T; - /** - * @hidden - */ - _Set_prev(it: ListIterator): void; - /** - * @hidden - */ - _Set_next(it: ListIterator): void; - /** - * @inheritdoc - */ - equal_to(obj: ListIterator): boolean; - /** - * @inheritdoc - */ - swap(obj: ListIterator): void; - } -} -declare namespace std { - /** - *

A reverse-iterator of List.

- * - *

- * - *

- * - * @param Type of the elements. - * - * @author Jeongho Nam - */ - class ListReverseIterator extends ReverseIterator, ListReverseIterator> { - /** - * Construct from base iterator. - * - * @param base A reference of the base iterator, which iterates in the opposite direction. - */ - constructor(base: ListIterator); - /** - * @hidden - */ - protected create_neighbor(base: ListIterator): ListReverseIterator; - /** - * @inheritdoc - */ - /** - * Set value of the iterator is pointing to. - * - * @param val Value to set. - */ - value: T; - } -} -declare namespace std { - /** - *

Priority queue.

- * - *

{@link PriorityQueue Priority queues} are a type of container adaptors, specifically designed such that its - * first element is always the greatest of the elements it contains, according to some strict weak ordering - * criterion.

- * - *

This context is similar to a heap, where elements can be inserted at any moment, and only the - * max heap element can be retrieved (the one at the top in the {@link PriorityQueue priority queue}).

- * - *

{@link PriorityQueue Priority queues} are implemented as container adaptors, which are classes that - * use an encapsulated object of a specific container class as its {@link container_ underlying container}, - * providing a specific set of member functions to access its elements. Elements are popped from the "back" - * of the specific container, which is known as the top of the {@link PriorityQueue Priority queue}.

- * - *

The {@link container_ underlying container} may be any of the standard container class templates or some - * other specifically designed container class. The container shall be accessible through - * {@link IArrayIterator random access iterators} and support the following operations:

- * - *
    - *
  • empty()
  • - *
  • size()
  • - *
  • front()
  • - *
  • push_back()
  • - *
  • pop_back()
  • - *
- * - *

The standard container classes {@link Vector} and {@link Deque} fulfill these requirements. By default, if - * no container class is specified for a particular {@link PriorityQueue} class instantiation, the standard - * container {@link Vector} is used.

- * - *

Support of {@link IArrayIterator random access iterators} is required to keep a heap structure internally - * at all times. This is done automatically by the container adaptor by automatically calling the algorithm - * functions make_heap, push_heap and pop_heap when needed.

- * - * @param Type of the elements. - * - * @reference http://www.cplusplus.com/reference/queue/priority_queue/ - * @author Jeongho Nam - */ - class PriorityQueue { - /** - *

The underlying container for implementing the priority queue.

- * - *

Following standard definition from the C++ committee, the underlying container should be one of - * {@link Vector} or {@link Deque}, however, I've adopted {@link TreeMultiSet} instead of them. Of course, - * there are proper reasons for adapting the {@link TreeMultiSet} even violating standard advice.

- * - *

Underlying container of {@link PriorityQueue} must keep a condition; the highest (or lowest) - * element must be placed on the terminal node for fast retrieval and deletion. To keep the condition with - * {@link Vector} or {@link Deque}, lots of times will only be spent for re-arranging elements. It calls - * rearrangement functions like make_heap, push_heap and pop_head for rearrangement.

- * - *

However, the {@link TreeMultiSet} container always keeps arrangment automatically without additional - * operations and it even meets full criteria of {@link PriorityQueue}. Those are the reason why I've adopted - * {@link TreeMultiSet} as the underlying container of {@link PriorityQueue}.

- */ - private container_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (left: T, right: T) => boolean); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - */ - constructor(array: Array); - /** - * Contruct from elements with compare. - * - * @param array Elements to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array, compare: (left: T, right: T) => boolean); - /** - * Copy Constructor. - */ - constructor(container: base.IContainer); - /** - * Copy Constructor with compare. - * - * @param container A container to be copied. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: base.IContainer, compare: (left: T, right: T) => boolean); - /** - * Range Constructor. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * Range Constructor with compare. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * @param compare A binary predicate determines order of elements. - */ - constructor(begin: Iterator, end: Iterator, compare: (left: T, right: T) => boolean); - /** - *

Return size.

- * - *

Returns the number of elements in the {@link PriorityQueue}.

- * - *

This member function effectively calls member {@link IArray.size size} of the - * {@link container_ underlying container} object.

- * - * @return The number of elements in the underlying - */ - size(): number; - /** - *

Test whether container is empty.

- * - *

Returns whether the {@link PriorityQueue} is empty: i.e. whether its {@link size} is zero.

- * - *

This member function effectively calls member {@link IARray.empty empty} of the - * {@link container_ underlying container} object.

- */ - empty(): boolean; - /** - *

Access top element.

- * - *

Returns a constant reference to the top element in the {@link PriorityQueue}.

- * - *

The top element is the element that compares higher in the {@link PriorityQueue}, and the next that is - * removed from the container when {@link PriorityQueue.pop} is called.

- * - *

This member function effectively calls member {@link IArray.front front} of the - * {@link container_ underlying container} object.

- * - * @return A reference to the top element in the {@link PriorityQueue}. - */ - top(): T; - /** - *

Insert element.

- * - *

Inserts a new element in the {@link PriorityQueue}. The content of this new element is initialized to - * val. - * - *

This member function effectively calls the member function {@link IArray.push_back push_back} of the - * {@link container_ underlying container} object, and then reorders it to its location in the heap by calling - * the push_heap algorithm on the range that includes all the elements of the

- * - * @param val Value to which the inserted element is initialized. - */ - push(val: T): void; - /** - *

Remove top element.

- * - *

Removes the element on top of the {@link PriorityQueue}, effectively reducing its {@link size} by one. - * The element removed is the one with the highest (or lowest) value.

- * - *

The value of this element can be retrieved before being popped by calling member - * {@link PriorityQueue.top}.

- * - *

This member function effectively calls the pop_heap algorithm to keep the heap property of - * {@link PriorityQueue PriorityQueues} and then calls the member function {@link IArray.pop_back pop_back} of - * the {@link container_ underlying container} object to remove the element.

- */ - pop(): void; - /** - *

Swap contents.

- * - *

Exchanges the contents of the container adaptor by those of obj, swapping both the - * {@link container_ underlying container} value and their comparison function using the corresponding - * {@link std.swap swap} non-member functions (unqualified).

- * - *

This member function has a noexcept specifier that matches the combined noexcept of the - * {@link IArray.swap swap} operations on the {@link container_ underlying container} and the comparison - * functions.

- * - * @param obj {@link PriorityQueue} container adaptor of the same type (i.e., instantiated with the same - * template parameters, T). Sizes may differ. - */ - swap(obj: PriorityQueue): void; - } -} -declare namespace std { - /** - *

FIFO queue.

- * - *

{@link Queue}s are a type of container adaptor, specifically designed to operate in a FIFO context - * (first-in first-out), where elements are inserted into one end of the container and extracted from the other. - *

- * - *

{@link Queue}s are implemented as containers adaptors, which are classes that use an encapsulated object of - * a specific container class as its underlying container, providing a specific set of member functions to access - * its elements. Elements are pushed into the {@link IDeque.back back()} of the specific container and popped from - * its {@link IDeque.front front()}.

- * - *

{@link container_ The underlying container} may be one of the standard container class template or some - * other specifically designed container class. This underlying container shall support at least the following - * operations:

- * - *
    - *
  • empty
  • - *
  • size
  • - *
  • front
  • - *
  • back
  • - *
  • push_back
  • - *
  • pop_front
  • - *
- * - *

The standard container classes {@link Deque} and {@link List} fulfill these requirements. - * By default, if no container class is specified for a particular {@link Queue} class instantiation, the standard - * container {@link List} is used.

- * - *

- * - *

- * - * @param Type of elements. - * - * @reference http://www.cplusplus.com/reference/queue/queue - * @author Jeongho Nam - */ - class Queue { - /** - * The underlying object for implementing the FIFO - */ - private container_; - /** - * Default Constructor. - */ - constructor(); - /** - * Copy Constructor. - */ - constructor(container: Queue); - /** - *

Return size.

- *

Returns the number of elements in the {@link Queue}.

- * - *

This member function effectively calls member {@link IDeque.size size()} of the - * {@link container_ underlying container} object.

- * - * @return The number of elements in the {@link container_ underlying container}. - */ - size(): number; - /** - *

Test whether container is empty.

- *

returns whether the {@link Queue} is empty: i.e. whether its size is zero.

- * - *

This member function efeectively calls member {@link IDeque.empty empty()} of the - * {@link container_ underlying container} object.

- * - * @return true if the {@link container_ underlying container}'s size is 0, - * false otherwise.

- */ - empty(): boolean; - /** - *

Access next element.

- *

Returns a value of the next element in the {@link Queue}.

- * - *

The next element is the "oldest" element in the {@link Queue} and the same element that is popped out - * from the queue when {@link pop Queue.pop()} is called.

- * - *

This member function effectively calls member {@link IDeque.front front()} of the - * {@link container_ underlying container} object.

- * - * @return A value of the next element in the {@link Queue}. - */ - front(): T; - /** - *

Access last element.

- * - *

Returns a vaue of the last element in the queue. This is the "newest" element in the queue (i.e. the - * last element pushed into the queue).

- * - *

This member function effectively calls the member function {@link IDeque.back back()} of the - * {@link container_ underlying container} object.

- * - * @return A value of the last element in the {@link Queue}. - */ - back(): T; - /** - *

Insert element.

- * - *

Inserts a new element at the end of the {@link Queue}, after its current last element. - * The content of this new element is initialized to val.

- * - *

This member function effectively calls the member function {@link IDeque.push_back push_back()} of the - * {@link container_ underlying container} object.

- * - * @param val Value to which the inserted element is initialized. - */ - push(val: T): void; - /** - *

Remove next element.

- * - *

Removes the next element in the {@link Queue}, effectively reducing its size by one.

- * - *

The element removed is the "oldest" element in the {@link Queue} whose value can be retrieved by calling - * member {@link front Queue.front()}

. - * - *

This member function effectively calls the member function {@link IDeque.pop_front pop_front()} of the - * {@link container_ underlying container} object.

- */ - pop(): void; - /** - *

Swap contents.

- * - *

Exchanges the contents of the container adaptor (this) by those of obj.

- * - *

This member function calls the non-member function {@link IContainer.swap swap} (unqualified) to swap - * the {@link container_ underlying containers}.

- * - * @param obj Another {@link Queue} container adaptor of the same type (i.e., instantiated with the same - * template parameter, T). Sizes may differ.

- */ - swap(obj: Queue): void; - } -} -declare namespace std { - /** - *

LIFO stack.

- * - *

{@link Stack}s are a type of container adaptor, specifically designed to operate in a LIFO context - * (last-in first-out), where elements are inserted and extracted only from one end of the

- * - *

{@link Stack}s are implemented as containers adaptors, which are classes that use an encapsulated object of - * a specific container class as its underlying container, providing a specific set of member functions to - * access its elements. Elements are pushed/popped from the {@link ILinearContainer.back back()} of the - * {@link ILinearContainer specific container}, which is known as the top of the {@link Stack}.

- * - *

{@link container_ The underlying container} may be any of the standard container class templates or some - * other specifically designed container class. The container shall support the following operations:

- * - *
    - *
  • empty
  • - *
  • size
  • - *
  • front
  • - *
  • back
  • - *
  • push_back
  • - *
  • pop_back
  • - *
- * - *

The standard container classes {@link Vector}, {@link Deque} and {@link List} fulfill these requirements. - * By default, if no container class is specified for a particular {@link Stack} class instantiation, the standard - * container {@link List} is used.

- * - *

- * - *

- * - * @param Type of elements. - * - * @reference http://www.cplusplus.com/reference/stack/stack - * @author Jeongho Nam - */ - class Stack { - /** - * The underlying object for implementing the LIFO - */ - private container_; - /** - * Default Constructor. - */ - constructor(); - /** - * Copy Constructor. - */ - constructor(stack: Stack); - /** - *

Return size.

- * - *

Returns the number of elements in the {@link Stack}.

- * - *

This member function effectively calls member {@link ILinearContainer.size size()} of the - * {@link container_ underlying container} object.

- * - * @return The number of elements in the {@link container_ underlying container}. - */ - size(): number; - /** - *

Test whether container is empty.

- * - *

returns whether the {@link Stack} is empty: i.e. whether its size is zero.

- * - *

This member function effectively calls member {@link ILinearContainer.empty empty()} of the - * {@link container_ underlying container} object.

- * - * @return true if the underlying container's size is 0, - * false otherwise.

- */ - empty(): boolean; - /** - *

Access next element.

- * - *

Returns a value of the top element in the {@link Stack}

. - * - *

Since {@link Stack}s are last-in first-out containers, the top element is the last element inserted into - * the {@link Stack}.

- * - *

This member function effectively calls member {@link ILinearContainer.back back()} of the - * {@link container_ underlying container} object.

- * - * @return A value of the top element in the {@link Stack}. - */ - top(): T; - /** - *

Insert element.

- * - *

Inserts a new element at the top of the {@link Stack}, above its current top element.

- * - *

This member function effectively calls the member function - * {@link ILinearContainer.push_back push_back()} of the {@link container_ underlying container} object.

- * - * @param val Value to which the inserted element is initialized. - */ - push(val: T): void; - /** - *

Remove top element.

- * - *

Removes the element on top of the {@link Stack}, effectively reducing its size by one.

- * - *

The element removed is the latest element inserted into the {@link Stack}, whose value can be retrieved - * by calling member {@link top Stack.top()}

. - * - *

This member function effectively calls the member function {@link ILinearContainer.pop_back pop_back()} - * of the {@link container_ underlying container} object.

- */ - pop(): void; - /** - *

Swap contents.

- * - *

Exchanges the contents of the container adaptor (this) by those of obj.

- * - *

This member function calls the non-member function {@link IContainer.swap swap} (unqualified) to swap - * the {@link container_ underlying containers}.

- * - * @param obj Another {@link Stack} container adaptor of the same type (i.e., instantiated with the same - * template parameter, T). Sizes may differ.

- */ - swap(obj: Stack): void; - } -} declare namespace std.base { /** *

An abstract error instance.

@@ -7816,1690 +3017,6 @@ declare namespace std.base { to_bool(): boolean; } } -declare namespace std { - /** - *

System error exception.

- * - *

This class defines the type of objects thrown as exceptions to report conditions originating during - * runtime from the operating system or other low-level application program interfaces which have an - * associated {@link ErrorCode}.

- * - *

The class inherits from {@link RuntimeError}, to which it adds an {@link ErrorCode} as - * member code (and defines a specialized what member).

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/system_error/system_error - * @author Jeongho Nam - */ - class SystemError extends RuntimeError { - /** - * @hidden - */ - protected code_: ErrorCode; - /** - * Construct from an error code. - * - * @param code An {@link ErrorCode} object. - */ - constructor(code: ErrorCode); - /** - * Construct from an error code and message. - * - * @param code An {@link ErrorCode} object. - * @param message A message incorporated in the string returned by member {@link what what()}. - */ - constructor(code: ErrorCode, message: string); - /** - * Construct from a numeric value and error category. - * - * @param val A numerical value identifying an error code. - * @param category A reference to an {@link ErrorCode} object. - */ - constructor(val: number, category: ErrorCategory); - /** - * Construct from a numeric value, error category and message. - * - * @param val A numerical value identifying an error code. - * @param category A reference to an {@link ErrorCode} object. - * @param message A message incorporated in the string returned by member {@link what what()}. - */ - constructor(val: number, category: ErrorCategory, message: string); - /** - *

Get error code.

- * - *

Returns the {@link ErrorCode} object associated with the exception.

- * - *

This value is either the {@link ErrorCode} passed to the construction or its equivalent - * (if constructed with a value and a {@link category}.

- * - * @return The {@link ErrorCode} associated with the object. - */ - code(): ErrorCode; - } -} -declare namespace std { - /** - *

Error category.

- * - *

This type serves as a base class for specific category types.

- * - *

Category types are used to identify the source of an error. They also define the relation between - * {@link ErrorCode} and {@link ErrorCondition}objects of its category, as well as the message set for {@link ErrorCode} - * objects. - * - *

Objects of these types have no distinct values and are not-copyable and not-assignable, and thus can only be - * passed by reference. As such, only one object of each of these types shall exist, each uniquely identifying its own - * category: all error codes and conditions of a same category shall return a reference to same object.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/system_error/error_category - * @author Jeongho Nam - */ - abstract class ErrorCategory { - /** - * Default Constructor. - */ - constructor(); - /** - *

Return category name.

- * - *

In derived classes, the function returns a string naming the category.

- * - *

In {@link ErrorCategory}, it is a pure virtual member function.

- * - *
    - *
  • In the {@link GenericCategory} object, it returns "generic".
  • - *
  • In the {@link SystemCategory} object, it returns "system".
  • - *
  • In the {@link IOStreamCategory} object, it returns "iostream".
  • - *
- * - * @return The category name. - */ - abstract name(): string; - /** - *

Error message.

- * - *

In derived classes, the function returns a string object with a message describing the error condition - * denoted by val.

- * - *

In {@link ErrorCategory}, it is a pure virtual member function.

- * - *

This function is called both by {@link ErrorCode.message ErrorCode.message()} and - * {@link ErrorCondition.message ErrorCondition.message()} to obtain the corresponding message in the - * {@link category}. Therefore, numerical values used by custom error codes and - * {@link ErrorCondition error conditions} should only match for a category if they describe the same error.

- * - * @param val A numerical value identifying an error condition. - * If the {@link ErrorCategory} object is the {@link GenericCategory}, this argument is equivalent to an - * {@link errno} value. - * - * @return A string object with the message. - */ - abstract message(val: number): string; - /** - *

Default error condition.

- * - *

Returns the default {@link ErrorCondition}object of this category that is associated with the - * {@link ErrorCode} identified by a value of val.

- * - *

Its definition in the base class {@link ErrorCategory} returns the same as constructing an - * {@link ErrorCondition} object with: - * - *

new ErrorCondition(val, *this);

- * - *

As a virtual member function, this behavior can be overriden in derived classes.

- * - *

This function is called by the default definition of member {@link equivalent equivalent()}, which is used to - * compare {@link ErrorCondition error conditions} with error codes.

- * - * @param val A numerical value identifying an error condition. - * - * @return The default {@link ErrorCondition}object associated with condition value val for this category. - */ - default_error_condition(val: number): ErrorCondition; - /** - *

Check error code equivalence.

- * - *

Checks whether, for the category, an {@link ErrorCode error code} is equivalent to an - * {@link ErrorCondition error condition.

- * - *

This function is called by the overloads of comparison operators when an {@link ErrorCondition} object is - * compared to an {@link ErrorCode} object to check for equality or inequality. If either one of those objects' - * {@link ErrorCategory categories} considers the other equivalent using this function, they are considered - * equivalent by the operator.

- * - *

As a virtual member function, this behavior can be overridden in derived classes to define a different - * correspondence mechanism for each {@link ErrorCategory} type.

- * - * @param val_code A numerical value identifying an error code. - * @param cond An object of an {@link ErrorCondition} type. - * - * @return true if the arguments are considered equivalent. false otherwise. - */ - equivalent(val_code: number, cond: ErrorCondition): boolean; - /** - *

Check error code equivalence.

- * - *

Checks whether, for the category, an {@link ErrorCode error code} is equivalent to an - * {@link ErrorCondition error condition.

- * - *

This function is called by the overloads of comparison operators when an {@link ErrorCondition} object is - * compared to an {@link ErrorCode} object to check for equality or inequality. If either one of those objects' - * {@link ErrorCategory categories} considers the other equivalent using this function, they are considered - * equivalent by the operator.

- * - *

As a virtual member function, this behavior can be overridden in derived classes to define a different - * correspondence mechanism for each {@link ErrorCategory} type.

- * - * @param code An object of an {@link ErrorCode} type. - * @param val_cond A numerical value identifying an error code. - * - * @return true if the arguments are considered equivalent. false otherwise. - */ - equivalent(code: ErrorCode, val_cond: number): boolean; - } -} -declare namespace std { - /** - *

Error condition.

- * - *

Objects of this type hold a condition {@link value} associated with a {@link category}.

- * - *

Objects of this type describe errors in a generic way so that they may be portable across different - * systems. This is in contrast with {@link ErrorCode} objects, that may contain system-specific - * information.

- * - *

Because {@link ErrorCondition}objects can be compared with error_code objects directly by using - * relational operators, {@link ErrorCondition}objects are generally used to check whether - * a particular {@link ErrorCode} obtained from the system matches a specific error condition no matter - * the system.

- * - *

The {@link ErrorCategory categories} associated with the {@link ErrorCondition} and the - * {@link ErrorCode} define the equivalences between them.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/system_error/error_condition - * @author Jeongho Nam - */ - class ErrorCondition extends base.ErrorInstance { - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from a numeric value and error category. - * - * @param val A numerical value identifying an error condition. - * @param category A reference to an {@link ErrorCategory} object. - */ - constructor(val: number, category: ErrorCategory); - } -} -declare namespace std { - /** - *

Error code.

- * - *

Objects of this type hold an error code {@link value} associated with a {@link category}.

- * - *

The operating system and other low-level applications and libraries generate numerical error codes to - * represent possible results. These numerical values may carry essential information for a specific platform, - * but be non-portable from one platform to another.

- * - *

Objects of this class associate such numerical codes to {@link ErrorCategory error categories}, so that they - * can be interpreted when needed as more abstract (and portable) {@link ErrorCondition error conditions}.

- * - *

- *

- * - * @reference http://www.cplusplus.com/reference/system_error/error_code - * @author Jeongho Nam - */ - class ErrorCode extends base.ErrorInstance { - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from a numeric value and error category. - * - * @param val A numerical value identifying an error code. - * @param category A reference to an {@link ErrorCategory} object. - */ - constructor(val: number, category: ErrorCategory); - } -} -declare namespace std.TreeMap { - type iterator = std.MapIterator; - type reverse_iterator = std.MapReverseIterator; -} -declare namespace std { - /** - *

Tree-structured map, std::map of STL.

- * - *

{@link TreeMap TreeMaps} are associative containers that store elements formed by a combination of a - * key value (Key) and a mapped value (T), following order.

- * - *

In a {@link TreeMap}, the key values are generally used to sort and uniquely identify the elements, - * while the mapped values store the content associated to this key. The types of key and - * mapped value may differ, and are grouped together in member type value_type, which is a {@link Pair} - * type combining both:

- * - *

typedef Pair value_type;

- * - *

Internally, the elements in a {@link TreeMap} are always sorted by its key following a - * strict weak ordering criterion indicated by its internal comparison method {@link less}. - * - *

{@link TreeMap} containers are generally slower than {@link HashMap HashMap} containers to access individual - * elements by their key, but they allow the direct iteration on subsets based on their order.

- * - *

{@link TreeMap}s are typically implemented as binary search trees.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
Elements in associative containers are referenced by their key and not by their absolute - * position in the container.
- * - *
Ordered
- *
The elements in the container follow a strict order at all times. All inserted elements are - * given a position in this order.
- * - *
Map
- *
Each element associates a key to a mapped value: - * Keys are meant to identify the elements whose main content is the mapped value.
- * - *
Unique keys
- *
No two elements in the container can have equivalent keys.
- *
- * - * @param Type of the keys. Each element in a map is uniquely identified by its key value. - * @param Type of the mapped value. Each element in a map stores some data as its mapped value. - * - * @reference http://www.cplusplus.com/reference/map/map - * @author Jeongho Nam - */ - class TreeMap extends base.UniqueMap implements base.ITreeMap { - /** - * @hidden - */ - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (x: Key, y: Key) => boolean); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - */ - constructor(array: Array>); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array>, compare: (x: Key, y: Key) => boolean); - /** - * Contruct from tuples. - * - * @param array Tuples to be contained. - */ - constructor(array: Array<[Key, T]>); - /** - * Contruct from tuples. - * - * @param array Tuples to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array<[Key, T]>, compare: (x: Key, y: Key) => boolean); - /** - * Copy Constructor. - * - * @param container Another map to copy. - */ - constructor(container: TreeMap); - /** - * Copy Constructor. - * - * @param container Another map to copy. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: TreeMap, compare: (x: Key, y: Key) => boolean); - /** - * Range Constructor. - * - * @param begin nput interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator>, end: Iterator>); - /** - * Range Constructor. - * - * @param begin nput interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * @param compare A binary predicate determines order of elements. - */ - constructor(begin: Iterator>, end: Iterator>, compare: (x: Key, y: Key) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: Key): MapIterator; - /** - * @inheritdoc - */ - key_comp(): (x: Key, y: Key) => boolean; - /** - * @inheritdoc - */ - value_comp(): (x: Pair, y: Pair) => boolean; - /** - * @inheritdoc - */ - lower_bound(key: Key): MapIterator; - /** - * @inheritdoc - */ - upper_bound(key: Key): MapIterator; - /** - * @inheritdoc - */ - equal_range(key: Key): Pair, MapIterator>; - /** - * @hidden - */ - protected _Insert_by_pair(pair: Pair): any; - /** - * @hidden - */ - protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; - /** - * @hidden - */ - protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: MapIterator, last: MapIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: MapIterator, last: MapIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link TreeMap map} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link TreeMap map container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link TreeMap container}. - */ - swap(obj: TreeMap): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer>): void; - } -} -declare namespace std.TreeMultiMap { - type iterator = std.MapIterator; - type reverse_iterator = std.MapReverseIterator; -} -declare namespace std { - /** - *

Tree-structured multiple-key map.

- * - *

{@link TreeMultiMap TreeMultiMaps} are associative containers that store elements formed by a combination of - * a key value and a mapped value, following a specific order, and where multiple elements can - * have equivalent keys.

- * - *

In a {@link TreeMultiMap}, the key values are generally used to sort and uniquely identify - * the elements, while the mapped values store the content associated to this key. The types of - * key and mapped value may differ, and are grouped together in member type - * value_type, which is a {@link Pair} type combining both:

- * - *

typedef Pair value_type;

- * - *

Internally, the elements in a {@link TreeMultiMap}are always sorted by its key following a - * strict weak ordering criterion indicated by its internal comparison method (of {@link less}).

- * - *

{@link TreeMultiMap}containers are generally slower than {@link HashMap} containers - * to access individual elements by their key, but they allow the direct iteration on subsets based - * on their order.

- * - *

{@link TreeMultiMap TreeMultiMaps} are typically implemented as binary search trees.

- * - *

< - * img src="http://samchon.github.io/typescript-stl/images/design/class_diagram/map_containers.png" style="max-width: 100%" />

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
- * - *
Ordered
- *
- * The elements in the container follow a strict order at all times. All inserted elements are - * given a position in this order. - *
- * - *
Map
- *
- * Each element associates a key to a mapped value: - * Keys are meant to identify the elements whose main content is the mapped value. - *
- * - *
Multiple equivalent keys
- *
Multiple elements in the container can have equivalent keys.
- *
- * - * @param Type of the keys. Each element in a map is uniquely identified by its key value. - * @param Type of the mapped value. Each element in a map stores some data as its mapped value. - * - * @reference http://www.cplusplus.com/reference/map/multimap - * @author Jeongho Nam - */ - class TreeMultiMap extends base.MultiMap implements base.ITreeMap { - /** - * @hidden - */ - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (x: Key, y: Key) => boolean); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - */ - constructor(array: Array>); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array>, compare: (x: Key, y: Key) => boolean); - /** - * Contruct from tuples. - * - * @param array Tuples to be contained. - */ - constructor(array: Array<[Key, T]>); - /** - * Contruct from tuples. - * - * @param array Tuples to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array<[Key, T]>, compare: (x: Key, y: Key) => boolean); - /** - * Copy Constructor. - * - * @param container Another map to copy. - */ - constructor(container: TreeMultiMap); - /** - * Copy Constructor. - * - * @param container Another map to copy. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: TreeMultiMap, compare: (x: Key, y: Key) => boolean); - /** - * Range Constructor. - * - * @param begin nput interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator>, end: Iterator>); - /** - * Range Constructor. - * - * @param begin nput interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * @param compare A binary predicate determines order of elements. - */ - constructor(begin: Iterator>, end: Iterator>, compare: (x: Key, y: Key) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: Key): MapIterator; - /** - * @inheritdoc - */ - count(key: Key): number; - /** - * @inheritdoc - */ - key_comp(): (x: Key, y: Key) => boolean; - /** - * @inheritdoc - */ - value_comp(): (x: Pair, y: Pair) => boolean; - /** - * @inheritdoc - */ - lower_bound(key: Key): MapIterator; - /** - * @inheritdoc - */ - upper_bound(key: Key): MapIterator; - /** - * @inheritdoc - */ - equal_range(key: Key): Pair, MapIterator>; - /** - * @hidden - */ - protected _Insert_by_pair(pair: Pair): any; - /** - * @hidden - */ - protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; - /** - * @hidden - */ - protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: MapIterator, last: MapIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: MapIterator, last: MapIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link TreeMapMulti map} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link TreeMapMulti map container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link TreeMapMulti container}. - */ - swap(obj: TreeMultiMap): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer>): void; - } -} -declare namespace std.TreeMultiSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

Tree-structured multiple-key set.

- * - *

{@link TreeMultiSet TreeMultiSets} are containers that store elements following a specific order, and - * where multiple elements can have equivalent values.

- * - *

In a {@link TreeMultiSet}, the value of an element also identifies it (the value is itself - * the key, of type T). The value of the elements in a {@link TreeMultiSet} cannot - * be modified once in the container (the elements are always const), but they can be inserted or removed - * from the

- * - *

Internally, the elements in a {@link TreeMultiSet TreeMultiSets} are always sorted following a strict - * weak ordering criterion indicated by its internal comparison method (of {@link IComparable.less less}).

- * - *

{@link TreeMultiSet} containers are generally slower than {@link HashMultiSet} containers - * to access individual elements by their key, but they allow the direct iteration on subsets based on - * their order.

- * - *

{@link TreeMultiSet TreeMultiSets} are typically implemented as binary search trees.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
- * - *
Ordered
- *
- * The elements in the container follow a strict order at all times. All inserted elements are - * given a position in this order. - *
- * - *
Set
- *
The value of an element is also the key used to identify it.
- * - *
Multiple equivalent keys
- *
Multiple elements in the container can have equivalent keys.
- *
- * - * @param Type of the elements. Each element in a {@link TreeMultiSet} container is also identified - * by this value (each value is itself also the element's key). - * - * @reference http://www.cplusplus.com/reference/set/multiset - * @author Jeongho Nam - */ - class TreeMultiSet extends base.MultiSet implements base.ITreeSet { - /** - * @hidden - */ - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (x: T, y: T) => boolean); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - */ - constructor(array: Array); - /** - * Contruct from elements with compare. - * - * @param array Elements to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array, compare: (x: T, y: T) => boolean); - /** - * Copy Constructor. - */ - constructor(container: TreeMultiSet); - /** - * Copy Constructor with compare. - * - * @param container A container to be copied. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: TreeMultiSet, compare: (x: T, y: T) => boolean); - /** - * Range Constructor. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * Construct from range and compare. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * @param compare A binary predicate determines order of elements. - */ - constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(val: T): SetIterator; - /** - * @inheritdoc - */ - count(val: T): number; - /** - * @inheritdoc - */ - key_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - value_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - lower_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - upper_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - equal_range(val: T): Pair, SetIterator>; - /** - * @hidden - */ - _Get_tree(): base.AtomicTree; - /** - * @hidden - */ - protected _Insert_by_val(val: T): any; - /** - * @hidden - */ - protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: SetIterator, last: SetIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link TreeMultiSet set} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link TreeMultiSet set container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link TreeMultiSet container}. - */ - swap(obj: TreeMultiSet): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } -} -declare namespace std.TreeSet { - type iterator = std.SetIterator; - type reverse_iterator = std.SetReverseIterator; -} -declare namespace std { - /** - *

Tree-structured set, std::set of STL.

- * - *

{@link TreeSet}s are containers that store unique elements following a specific order.

- * - *

In a {@link TreeSet}, the value of an element also identifies it (the value is itself the - * key, of type T), and each value must be unique. The value of the elements in a - * {@link TreeSet} cannot be modified once in the container (the elements are always const), but they - * can be inserted or removed from the

- * - *

Internally, the elements in a {@link TreeSet} are always sorted following a specific strict weak - * ordering criterion indicated by its internal comparison method (of {@link less}).

- * - *

{@link TreeSet} containers are generally slower than {@link HashSet} containers to access - * individual elements by their key, but they allow the direct iteration on subsets based on their - * order.

- * - *

{@link TreeSet}s are typically implemented as binary search trees.

- * - *

- *

- * - *

Container properties

- *
- *
Associative
- *
- * Elements in associative containers are referenced by their key and not by their absolute - * position in the container. - *
- * - *
Ordered
- *
- * The elements in the container follow a strict order at all times. All inserted elements are - * given a position in this order. - *
- * - *
Set
- *
The value of an element is also the key used to identify it.
- * - *
Unique keys
- *
No two elements in the container can have equivalent keys.
- *
- * - * @param Type of the elements. - * Each element in an {@link TreeSet} is also uniquely identified by this value. - * - * @reference http://www.cplusplus.com/reference/set/set - * @author Jeongho Nam - */ - class TreeSet extends base.UniqueSet implements base.ITreeSet { - /** - * @hidden - */ - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (x: T, y: T) => boolean); - /** - * Contruct from elements. - * - * @param array Elements to be contained. - */ - constructor(array: Array); - /** - * Contruct from elements with compare. - * - * @param array Elements to be contained. - * @param compare A binary predicate determines order of elements. - */ - constructor(array: Array, compare: (x: T, y: T) => boolean); - /** - * Copy Constructor. - */ - constructor(container: TreeMultiSet); - /** - * Copy Constructor with compare. - * - * @param container A container to be copied. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: TreeMultiSet, compare: (x: T, y: T) => boolean); - /** - * Range Constructor. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * Construct from range and compare. - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * @param compare A binary predicate determines order of elements. - */ - constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(val: T): SetIterator; - /** - * @inheritdoc - */ - key_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - value_comp(): (x: T, y: T) => boolean; - /** - * @inheritdoc - */ - lower_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - upper_bound(val: T): SetIterator; - /** - * @inheritdoc - */ - equal_range(val: T): Pair, SetIterator>; - /** - * @hidden - */ - protected _Insert_by_val(val: T): any; - protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; - /** - * @hidden - */ - protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; - /** - * @inheritdoc - */ - protected _Handle_insert(first: SetIterator, last: SetIterator): void; - /** - * @inheritdoc - */ - protected _Handle_erase(first: SetIterator, last: SetIterator): void; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link TreeSet set} of the same type. Sizes abd container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were - * in obj before the call, and the elements of obj are those which were in this. All - * iterators, references and pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link TreeSet set container} of the same type of elements as this (i.e., - * with the same template parameters, Key and T) whose content is swapped - * with that of this {@link TreeSet container}. - */ - swap(obj: TreeSet): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } -} -declare namespace std { - /** - *

Running on Node.

- * - *

Test whether the JavaScript is running on Node.

- * - * @references http://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser - */ - function is_node(): boolean; - /** - *

Pair of values.

- * - *

This class couples together a pair of values, which may be of different types (T1 and - * T2). The individual values can be accessed through its public members {@link first} and - * {@link second}.

- * - * @param Type of member {@link first}. - * @param Type of member {@link second}. - * - * @reference http://www.cplusplus.com/reference/utility/pair - * @author Jeongho Nam - */ - class Pair { - /** - *

A first value in the Pair.

- */ - first: T1; - /** - *

A second value in the Pair.

- */ - second: T2; - /** - *

Construct from pair values.

- * - * @param first The first value of the Pair - * @param second The second value of the Pair - */ - constructor(first: T1, second: T2); - /** - *

Whether a Pair is equal with the Pair.

- *

Compare each first and second value of two Pair(s) and returns whether they are equal or not.

- * - *

If stored key and value in a Pair are not number or string but an object like a class or struct, - * the comparison will be executed by a member method (SomeObject)::equal_to(). If the object does not have - * the member method equal_to(), only address of pointer will be compared.

- * - * @param obj A Map to compare - * @return Indicates whether equal or not. - */ - equal_to(pair: Pair): boolean; - less(pair: Pair): boolean; - } - /** - *

Construct {@link Pair} object.

- * - *

Constructs a {@link Pair} object with its {@link Pair.first first} element set to x and its - * {@link Pair.second second} element set to y.

- * - *

The template types can be implicitly deduced from the arguments passed to {@link make_pair}.

- * - *

{@link Pair} objects can be constructed from other {@link Pair} objects containing different types, if the - * respective types are implicitly convertible.

- * - * @param x Value for member {@link Pair.first first}. - * @param y Value for member {@link Pair.second second}. - * - * @return A {@link Pair} object whose elements {@link Pair.first first} and {@link Pair.second second} are set to - * x and y respectivelly. - */ - function make_pair(x: T1, y: T2): Pair; -} -declare namespace std.Vector { - type iterator = std.VectorIterator; - type reverse_iterator = std.VectorReverseIterator; -} -declare namespace std { - /** - *

Vector, the dynamic array.

- * - *

{@link Vector}s are sequence containers representing arrays that can change in size.

- * - *

Just like arrays, {@link Vector}s use contiguous storage locations for their elements, which means that - * their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently - * as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled - * automatically by the

- * - *

Internally, {@link Vector}s use a dynamically allocated array to store their elements. This array may need - * to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new - * array and moving all elements to it. This is a relatively expensive task in terms of processing time, and - * thus, {@link Vector}s do not reallocate each time an element is added to the

- * - *

Instead, {@link Vector} containers may allocate some extra storage to accommodate for possible growth, and - * thus the container may have an actual {@link capacity} greater than the storage strictly needed to contain its - * elements (i.e., its {@link size}). Libraries can implement different strategies for growth to balance between - * memory usage and reallocations, but in any case, reallocations should only happen at logarithmically growing - * intervals of {@link size} so that the insertion of individual elements at the end of the {@link Vector} can be - * provided with amortized constant time complexity (see {@link push_back push_back()}).

- * - *

Therefore, compared to arrays, {@link Vector}s consume more memory in exchange for the ability to manage - * storage and grow dynamically in an efficient way.

- * - *

Compared to the other dynamic sequence containers ({@link Deque}s, {@link List}s), {@link Vector Vectors} - * are very efficient accessing its elements (just like arrays) and relatively efficient adding or removing - * elements from its end. For operations that involve inserting or removing elements at positions other than the - * end, they perform worse than the others, and have less consistent iterators and references than {@link List}s. - *

- * - *

- * - *

- * - *

Container properties

- *
- *
Sequence
- *
- * Elements in sequence containers are ordered in a strict linear sequence. Individual elements are - * accessed by their position in this sequence. - *
- * - *
Dynamic array
- *
- * Allows direct access to any element in the sequence, even through pointer arithmetics, and provides - * relatively fast addition/removal of elements at the end of the sequence. - *
- *
- * - * @param Type of the elements. - * - * @reference http://www.cplusplus.com/reference/vector/vector - * @author Jeongho Nam - */ - class Vector extends Array implements base.IContainer, base.IArrayContainer { - /** - *

Default Constructor.

- * - *

Constructs an empty container, with no elements.

- */ - constructor(); - /** - * @inheritdoc - */ - constructor(array: Array); - /** - *

Initializer list Constructor.

- * - *

Constructs a container with a copy of each of the elements in array, in the same order.

- * - * @param array An array containing elements to be copied and contained. - */ - constructor(n: number); - /** - *

Fill Constructor.

- * - *

Constructs a container with n elements. Each element is a copy of val (if provided).

- * - * @param n Initial container size (i.e., the number of elements in the container at construction). - * @param val Value to fill the container with. Each of the n elements in the container is - * initialized to a copy of this value. - */ - constructor(n: number, val: T); - /** - *

Copy Constructor.

- * - *

Constructs a container with a copy of each of the elements in container, in the same order.

- * - * @param container Another container object of the same type (with the same class template - * arguments T), whose contents are either copied or acquired. - */ - constructor(container: Vector); - /** - *

Range Constructor.

- * - *

Constructs a container with as many elements as the range (begin, end), with each - * element emplace-constructed from its corresponding element in that range, in the same order.

- * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - constructor(begin: Iterator, end: Iterator); - /** - * @inheritdoc - */ - assign>(begin: InputIterator, end: InputIterator): void; - /** - * @inheritdoc - */ - assign(n: number, val: T): void; - /** - * @inheritdoc - */ - reserve(size: number): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - begin(): VectorIterator; - /** - * @inheritdoc - */ - end(): VectorIterator; - /** - * @inheritdoc - */ - rbegin(): VectorReverseIterator; - /** - * @inheritdoc - */ - rend(): VectorReverseIterator; - /** - * @inheritdoc - */ - size(): number; - /** - * @inheritdoc - */ - capacity(): number; - /** - * @inheritdoc - */ - empty(): boolean; - /** - * @inheritdoc - */ - at(index: number): T; - /** - * @inheritdoc - */ - set(index: number, val: T): T; - /** - * @inheritdoc - */ - front(): T; - /** - * @inheritdoc - */ - back(): T; - /** - * @inheritdoc - */ - push_back(val: T): void; - /** - *

Insert an element.

- * - *

The {@link Vector} is extended by inserting new element before the element at the specified - * position, effectively increasing the container size by one.

- * - *

This causes an automatic reallocation of the allocated storage space if -and only if- the new - * {@link size} surpasses the current {@link capacity}.

- * - *

Because {@link Vector}s use an Array as their underlying storage, inserting element in - * positions other than the {@link end end()} causes the container to relocate all the elements that were - * after position to its new position. This is generally an inefficient operation compared to the one - * performed for the same operation by other kinds of sequence containers (such as {@link List}).

- * - * @param position Position in the {@link Vector} where the new element is inserted. - * {@link iterator} is a member type, defined as a - * {@link VectorIterator random access iterator} type that points to elements. - * @param val Value to be copied to the inserted element. - * - * @return An iterator that points to the newly inserted element. - */ - insert(position: VectorIterator, val: T): VectorIterator; - /** - *

Insert elements by repeated filling.

- * - *

The {@link Vector} is extended by inserting new elements before the element at the specified - * position, effectively increasing the container size by the number of elements inserted.

- * - *

This causes an automatic reallocation of the allocated storage space if -and only if- the new - * {@link size} surpasses the current {@link capacity}.

- * - *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in - * positions other than the {@link end end()} causes the container to relocate all the elements that were - * after position to their new positions. This is generally an inefficient operation compared to the - * one performed for the same operation by other kinds of sequence containers (such as {@link List}). - * - * @param position Position in the {@link Vector} where the new elements are inserted. - * {@link iterator} is a member type, defined as a - * {@link VectorIterator random access iterator} type that points to elements. - * @param n Number of elements to insert. Each element is initialized to a copy of val. - * @param val Value to be copied (or moved) to the inserted elements. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert(position: VectorIterator, n: number, val: T): VectorIterator; - /** - *

Insert elements by range iterators.

- * - *

The {@link Vector} is extended by inserting new elements before the element at the specified - * position, effectively increasing the container size by the number of elements inserted by range - * iterators.

- * - *

This causes an automatic reallocation of the allocated storage space if -and only if- the new - * {@link size} surpasses the current {@link capacity}.

- * - *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in - * positions other than the {@link end end()} causes the container to relocate all the elements that were - * after position to their new positions. This is generally an inefficient operation compared to the - * one performed for the same operation by other kinds of sequence containers (such as {@link List}). - * - * @param position Position in the {@link Vector} where the new elements are inserted. - * {@link iterator} is a member type, defined as a - * {@link VectorIterator random access iterator} type that points to elements. - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert>(position: VectorIterator, begin: InputIterator, end: InputIterator): VectorIterator; - /** - *

Insert an element.

- * - *

The {@link Vector} is extended by inserting new element before the element at the specified - * position, effectively increasing the container size by one.

- * - *

This causes an automatic reallocation of the allocated storage space if -and only if- the new - * {@link size} surpasses the current {@link capacity}.

- * - *

Because {@link Vector}s use an Array as their underlying storage, inserting element in - * positions other than the {@link end end()} causes the container to relocate all the elements that were - * after position to its new position. This is generally an inefficient operation compared to the one - * performed for the same operation by other kinds of sequence containers (such as {@link List}).

- * - * @param position Position in the {@link Vector} where the new element is inserted. - * {@link iterator} is a member type, defined as a - * {@link VectorIterator random access iterator} type that points to elements. - * @param val Value to be copied to the inserted element. - * - * @return An iterator that points to the newly inserted element. - */ - insert(position: VectorReverseIterator, val: T): VectorReverseIterator; - /** - *

Insert elements by repeated filling.

- * - *

The {@link Vector} is extended by inserting new elements before the element at the specified - * position, effectively increasing the container size by the number of elements inserted.

- * - *

This causes an automatic reallocation of the allocated storage space if -and only if- the new - * {@link size} surpasses the current {@link capacity}.

- * - *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in - * positions other than the {@link end end()} causes the container to relocate all the elements that were - * after position to their new positions. This is generally an inefficient operation compared to the - * one performed for the same operation by other kinds of sequence containers (such as {@link List}). - * - * @param position Position in the {@link Vector} where the new elements are inserted. - * {@link iterator} is a member type, defined as a - * {@link VectorIterator random access iterator} type that points to elements. - * @param n Number of elements to insert. Each element is initialized to a copy of val. - * @param val Value to be copied (or moved) to the inserted elements. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert(position: VectorReverseIterator, n: number, val: T): VectorReverseIterator; - /** - *

Insert elements by range iterators.

- * - *

The {@link Vector} is extended by inserting new elements before the element at the specified - * position, effectively increasing the container size by the number of elements inserted by range - * iterators.

- * - *

This causes an automatic reallocation of the allocated storage space if -and only if- the new - * {@link size} surpasses the current {@link capacity}.

- * - *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in - * positions other than the {@link end end()} causes the container to relocate all the elements that were - * after position to their new positions. This is generally an inefficient operation compared to the - * one performed for the same operation by other kinds of sequence containers (such as {@link List}). - * - * @param position Position in the {@link Vector} where the new elements are inserted. - * {@link iterator} is a member type, defined as a - * {@link VectorIterator random access iterator} type that points to elements. - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - * - * @return An iterator that points to the first of the newly inserted elements. - */ - insert>(position: VectorReverseIterator, begin: InputIterator, end: InputIterator): VectorReverseIterator; - /** - * @hidden - */ - private insert_by_val(position, val); - /** - * @hidden - */ - protected _Insert_by_repeating_val(position: VectorIterator, n: number, val: T): VectorIterator; - /** - * @hidden - */ - protected _Insert_by_range>(position: VectorIterator, first: InputIterator, last: InputIterator): VectorIterator; - /** - * @inheritdoc - */ - pop_back(): void; - /** - *

Erase element.

- * - *

Removes from the {@link Vector} either a single element; position.

- * - *

This effectively reduces the container size by the number of element removed.

- * - *

Because {@link Vector}s use an Array as their underlying storage, erasing an element in - * position other than the {@link end end()} causes the container to relocate all the elements after the - * segment erased to their new positions. This is generally an inefficient operation compared to the one - * performed for the same operation by other kinds of sequence containers (such as {@link List}).

- * - * @param position Iterator pointing to a single element to be removed from the {@link Vector}. - * - * @return An iterator pointing to the new location of the element that followed the last element erased by - * the function call. This is the {@link end end()} if the operation erased the last element in the - * sequence. - */ - erase(position: VectorIterator): VectorIterator; - /** - *

Erase element.

- * - *

Removes from the Vector either a single element; position.

- * - *

This effectively reduces the container size by the number of elements removed.

- * - *

Because {@link Vector}s use an Array as their underlying storage, erasing elements in - * position other than the {@link end end()} causes the container to relocate all the elements after the - * segment erased to their new positions. This is generally an inefficient operation compared to the one - * performed for the same operation by other kinds of sequence containers (such as {@link List}).

- * - * @param begin An iterator specifying a range of beginning to erase. - * @param end An iterator specifying a range of end to erase. - * - * @return An iterator pointing to the new location of the element that followed the last element erased by - * the function call. This is the {@link rend rend()} if the operation erased the last element in the - * sequence. - */ - erase(first: VectorIterator, last: VectorIterator): VectorIterator; - /** - *

Erase element.

- * - *

Removes from the {@link Vector} either a single element; position.

- * - *

This effectively reduces the container size by the number of element removed.

- * - *

Because {@link Vector}s use an Array as their underlying storage, erasing an element in - * position other than the {@link end end()} causes the container to relocate all the elements after the - * segment erased to their new positions. This is generally an inefficient operation compared to the one - * performed for the same operation by other kinds of sequence containers (such as {@link List}).

- * - * @param position Iterator pointing to a single element to be removed from the {@link Vector}. - * - * @return An iterator pointing to the new location of the element that followed the last element erased by - * the function call. This is the {@link rend rend()} if the operation erased the last element in the - * sequence. - */ - erase(position: VectorReverseIterator): VectorReverseIterator; - /** - *

Erase element.

- * - *

Removes from the Vector either a single element; position.

- * - *

This effectively reduces the container size by the number of elements removed.

- * - *

Because {@link Vector}s use an Array as their underlying storage, erasing elements in - * position other than the {@link end end()} causes the container to relocate all the elements after the - * segment erased to their new positions. This is generally an inefficient operation compared to the one - * performed for the same operation by other kinds of sequence containers (such as {@link List}).

- * - * @param begin An iterator specifying a range of beginning to erase. - * @param end An iterator specifying a range of end to erase. - * - * @return An iterator pointing to the new location of the element that followed the last element erased by - * the function call. This is the {@link end end()} if the operation erased the last element in the - * sequence. - */ - erase(first: VectorReverseIterator, last: VectorReverseIterator): VectorReverseIterator; - /** - * @hidden - */ - protected _Erase_by_range(first: VectorIterator, last: VectorIterator): VectorIterator; - /** - *

Swap content.

- * - *

Exchanges the content of the container by the content of obj, which is another - * {@link Vector container} object with same type of elements. Sizes and container type may differ.

- * - *

After the call to this member function, the elements in this container are those which were in obj - * before the call, and the elements of obj are those which were in this. All iterators, references and - * pointers remain valid for the swapped objects.

- * - *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that - * algorithm with an optimization that behaves like this member function.

- * - * @param obj Another {@link Vector container} of the same type of elements (i.e., instantiated - * with the same template parameter, T) whose content is swapped with that of this - * {@link container Vector}. - */ - obj(obj: Vector): void; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } -} -declare namespace std { - /** - *

An iterator of Vector.

- * - *

- * - *

- * - * @param Type of the elements. - * - * @author Jeongho Nam - */ - class VectorIterator extends Iterator implements base.IArrayIterator { - /** - * Sequence number of iterator in the source {@link Vector}. - */ - private index_; - /** - *

Construct from the source {@link Vector container}.

- * - *

Note

- *

Do not create the iterator directly, by yourself.

- *

Use {@link Vector.begin begin()}, {@link Vector.end end()} in {@link Vector container} instead.

- * - * @param source The source {@link Vector container} to reference. - * @param index Sequence number of the element in the source {@link Vector}. - */ - constructor(source: Vector, index: number); - /** - * @hidden - */ - private vector; - /** - * @inheritdoc - */ - /** - * Set value of the iterator is pointing to. - * - * @param val Value to set. - */ - value: T; - /** - * Get index. - */ - index: number; - /** - * @inheritdoc - */ - prev(): VectorIterator; - /** - * @inheritdoc - */ - next(): VectorIterator; - /** - * @inheritdoc - */ - advance(n: number): VectorIterator; - /** - *

Whether an iterator is equal with the iterator.

- * - *

Compare two iterators and returns whether they are equal or not.

- * - *

Note

- *

Iterator's equal_to() only compare souce container and index number.

- * - *

Although elements in a pair, key and value are equal_to, if the source map or - * index number is different, then the {@link equal_to equal_to()} will return false. If you want to - * compare the elements of a pair, compare them directly by yourself.

- * - * @param obj An iterator to compare - * @return Indicates whether equal or not. - */ - equal_to(obj: VectorIterator): boolean; - /** - * @inheritdoc - */ - swap(obj: VectorIterator): void; - } -} -declare namespace std { - /** - *

A reverse-iterator of Vector.

- * - *

- * - *

- * - * @param Type of the elements. - * - * @author Jeongho Nam - */ - class VectorReverseIterator extends ReverseIterator, VectorReverseIterator> implements base.IArrayIterator { - /** - * Construct from base iterator. - * - * @param base A reference of the base iterator, which iterates in the opposite direction. - */ - constructor(base: VectorIterator); - /** - * @hidden - */ - protected create_neighbor(base: VectorIterator): VectorReverseIterator; - /** - * @inheritdoc - */ - /** - * Set value of the iterator is pointing to. - * - * @param val Value to set. - */ - value: T; - /** - * Get index. - */ - index: number; - } -} -declare namespace std.base { - /** - *

Static class holding enumeration codes of color of Red-black tree.

- * - *

Color codes imposed to nodes of RB-Tree are following those rules:

- * - *
    - *
  1. A node is either red or black.
  2. - *
  3. The root is black. This rule is sometimes omitted. Since the root can - * always be changed from red to black, but not - * necessarily vice versa, this rule has little effect on analysis.
  4. - *
  5. All leaves (NIL; null) are black.
  6. - *
  7. If a node is red, then both its children are - * black.
  8. - *
  9. Every path from a given node to any of its descendant NIL nodes contains the same number of - * black nodes. Some definitions: the number of - * black nodes from the root to a node is the node's - * black depth; the uniform number of black - * nodes in all paths from root to the leaves is called the black-height of - * the red-black tree.
  10. - *
- * - * @author Migrated by Jeongho Nam - */ - enum Color { - /** - *

Code of color black.

- * - *
    - *
  • Those are clearly black: root, leaf nodes or children nodes of red.
  • - *
  • Every path from a given nodes containes the same number of black nodes exclude NIL(s).
  • - *
- */ - BLACK = 0, - /** - *

Code of color red.

- */ - RED = 1, - } -} declare namespace std.base { enum Hash { MIN_SIZE = 10, @@ -10636,6 +4153,1440 @@ declare namespace std.base { insert>(position: Iterator, begin: InputIterator, end: InputIterator): Iterator; } } +declare namespace std { + /** + *

Bi-directional iterator.

+ * + *

{@link Iterator Bidirectional iterators} are iterators that can be used to access the sequence of elements + * in a range in both directions (towards the end and towards the beginning).

+ * + *

All {@link IArrayIterator random-access iterators} are also valid {@link Iterrator bidirectional iterators}. + *

+ * + *

There is not a single type of {@link Iterator bidirectional iterator}: {@link IContainer Each container} + * may define its own specific iterator type able to iterate through it and access its elements.

+ * + *

+ * + *

+ * + * @reference http://www.cplusplus.com/reference/iterator/BidirectionalIterator + * @author Jeongho Nam + */ + abstract class Iterator { + /** + * Source container of the iterator is directing for. + */ + protected source_: base.IContainer; + /** + * Construct from the source {@link IContainer container}. + * + * @param source The source + */ + constructor(source: base.IContainer); + /** + *

Get iterator to previous element.

+ *

If current iterator is the first item(equal with {@link IContainer.begin IContainer.begin()}), + * returns {@link IContainer.end IContainer.end()}.

+ * + * @return An iterator of the previous item. + */ + abstract prev(): Iterator; + /** + *

Get iterator to next element.

+ *

If current iterator is the last item, returns {@link IContainer.end IContainer.end()}.

+ * + * @return An iterator of the next item. + */ + abstract next(): Iterator; + /** + * Advances the {@link Iterator} by n element positions. + * + * @param n Number of element positions to advance. + * @return An advanced iterator. + */ + advance(n: number): Iterator; + /** + * Get source + */ + get_source(): base.IContainer; + /** + *

Whether an iterator is equal with the iterator.

+ * + *

Compare two iterators and returns whether they are equal or not.

+ * + *

Note

+ *

Iterator's equal_to() only compare souce container and index number.

+ * + *

Although elements in a pair, key and value are equal_to, if the source map or + * index number is different, then the {@link equal_to equal_to()} will return false. If you want to + * compare the elements of a pair, compare them directly by yourself.

+ * + * @param obj An iterator to compare + * @return Indicates whether equal or not. + */ + equal_to(obj: Iterator): boolean; + /** + *

Get value of the iterator is pointing.

+ * + * @return A value of the iterator. + */ + readonly value: T; + abstract swap(obj: Iterator): void; + } +} +declare namespace std { + /** + *

This class reverses the direction in which a bidirectional or random-access iterator iterates through a range. + *

+ * + *

A copy of the original iterator (the {@link Iterator base iterator}) is kept internally and used to reflect + * the operations performed on the {@link ReverseIterator}: whenever the {@link ReverseIterator} is incremented, its + * {@link Iterator base iterator} is decreased, and vice versa. A copy of the {@link Iterator base iterator} with the + * current state can be obtained at any time by calling member {@link base}.

+ * + *

Notice however that when an iterator is reversed, the reversed version does not point to the same element in + * the range, but to the one preceding it. This is so, in order to arrange for the past-the-end element of a + * range: An iterator pointing to a past-the-end element in a range, when reversed, is pointing to the last element + * (not past it) of the range (this would be the first element of the reversed range). And if an iterator to the + * first element in a range is reversed, the reversed iterator points to the element before the first element (this + * would be the past-the-end element of the reversed range).

+ * + *

+ * + *

+ * + * @reference http://www.cplusplus.com/reference/iterator/reverse_iterator + * @author Jeongho Nam + */ + abstract class ReverseIterator, This extends ReverseIterator> extends Iterator { + /** + * @hidden + */ + protected base_: Base; + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ + constructor(base: Base); + /** + *

Return base iterator.

+ * + *

Return a reference of the base iteraotr.

+ * + *

The base iterator is an iterator of the same type as the one used to construct the {@link ReverseIterator}, + * but pointing to the element next to the one the {@link ReverseIterator} is currently pointing to + * (a {@link ReverseIterator} has always an offset of -1 with respect to its base iterator). + * + * @return A reference of the base iterator, which iterates in the opposite direction. + */ + base(): Base; + /** + * @hidden + */ + protected abstract create_neighbor(base: Base): This; + /** + *

Get value of the iterator is pointing.

+ * + * @return A value of the reverse iterator. + */ + readonly value: T; + /** + * @inheritdoc + */ + prev(): This; + /** + * @inheritdoc + */ + next(): This; + /** + * @inheritdoc + */ + advance(n: number): This; + /** + * @inheritdoc + */ + equal_to(obj: This): boolean; + /** + * @inheritdoc + */ + swap(obj: This): void; + } + /** + *

Return distance between {@link Iterator iterators}.

+ * + *

Calculates the number of elements between first and last.

+ * + *

If it is a {@link IArrayIterator random-access iterator}, the function uses operator- to calculate this. + * Otherwise, the function uses the increase operator {@link Iterator.next next()} repeatedly.

+ * + * @param first Iterator pointing to the initial element. + * @param last Iterator pointing to the final element. This must be reachable from first. + * + * @return The number of elements between first and last. + */ + function distance>(first: InputIterator, last: InputIterator): number; + /** + *

Advance iterator.

+ * + *

Advances the iterator it by n elements positions.

+ * + * @param it Iterator to be advanced. + * @param n Number of element positions to advance. + * + * @return An iterator to the element n positions before it. + */ + function advance>(it: InputIterator, n: number): InputIterator; + /** + *

Get iterator to previous element.

+ * + *

Returns an iterator pointing to the element that it would be pointing to if advanced -n positions.

+ * + * @param it Iterator to base position. + * @param n Number of element positions offset (1 by default). + * + * @return An iterator to the element n positions before it. + */ + function prev>(it: BidirectionalIterator, n?: number): BidirectionalIterator; + /** + *

Get iterator to next element.

+ * + *

Returns an iterator pointing to the element that it would be pointing to if advanced n positions.

+ * + * @param it Iterator to base position. + * @param n Number of element positions offset (1 by default). + * + * @return An iterator to the element n positions away from it. + */ + function next>(it: ForwardIterator, n?: number): ForwardIterator; + /** + *

Iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the sequence.

+ * + *

If the sequence is empty, the returned value shall not be dereferenced.

+ * + * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. + * + * @return The same as returned by {@link IContainer.begin container.begin()}. + */ + function begin(container: Vector): VectorIterator; + /** + *

Iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the sequence.

+ * + *

If the sequence is empty, the returned value shall not be dereferenced.

+ * + * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. + * + * @return The same as returned by {@link IContainer.begin container.begin()}. + */ + function begin(container: List): ListIterator; + /** + *

Iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the sequence.

+ * + *

If the sequence is empty, the returned value shall not be dereferenced.

+ * + * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. + * + * @return The same as returned by {@link IContainer.begin container.begin()}. + */ + function begin(container: Deque): DequeIterator; + /** + *

Iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the sequence.

+ * + *

If the sequence is empty, the returned value shall not be dereferenced.

+ * + * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. + * + * @return The same as returned by {@link IContainer.begin container.begin()}. + */ + function begin(container: base.SetContainer): SetIterator; + /** + *

Iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the sequence.

+ * + *

If the sequence is empty, the returned value shall not be dereferenced.

+ * + * @param container A container object of a class type for which member {@link IContainer.begin begin} is defined. + * + * @return The same as returned by {@link IContainer.begin container.begin()}. + */ + function begin(container: base.MapContainer): MapIterator; + /** + *

Iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the sequence.

+ * + *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

+ * + * @param container A container of a class type for which member {@link IContainer.end end} is defined. + * + * @return The same as returned by {@link IContainer.end container.end()}. + */ + function end(container: Vector): VectorIterator; + /** + *

Iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the sequence.

+ * + *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

+ * + * @param container A container of a class type for which member {@link IContainer.end end} is defined. + * + * @return The same as returned by {@link IContainer.end container.end()}. + */ + function end(container: List): ListIterator; + /** + *

Iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the sequence.

+ * + *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

+ * + * @param container A container of a class type for which member {@link IContainer.end end} is defined. + * + * @return The same as returned by {@link IContainer.end container.end()}. + */ + function end(container: Deque): DequeIterator; + /** + *

Iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the sequence.

+ * + *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

+ * + * @param container A container of a class type for which member {@link IContainer.end end} is defined. + * + * @return The same as returned by {@link IContainer.end container.end()}. + */ + function end(container: base.SetContainer): SetIterator; + /** + *

Iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the sequence.

+ * + *

If the sequence is {@link IContainer.empty empty}, the returned value compares equal to the one returned by {@link begin} with the same argument.

+ * + * @param container A container of a class type for which member {@link IContainer.end end} is defined. + * + * @return The same as returned by {@link IContainer.end container.end()}. + */ + function end(container: base.MapContainer): MapIterator; +} +declare namespace std.base { + /** + *

An abstract map.

+ * + *

{@link MapContainer MapContainers} are associative containers that store elements formed by a combination + * of a key value (Key) and a mapped value (T), and which allows for fast retrieval + * of individual elements based on their keys.

+ * + *

In a {@link MapContainer}, the key values are generally used to identify the elements, while the + * mapped values store the content associated to this key. The types of key and + * mapped value may differ, and are grouped together in member type value_type, which is a + * {@link Pair} type combining both:

+ * + *

typedef pair value_type;

+ * + *

{@link MapContainer} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute position + * in the container. + *
+ * + *
Map
+ *
+ * Each element associates a key to a mapped value: + * Keys are meant to identify the elements whose main content is the mapped value. + *
+ *
+ * + * @param Type of the keys. Each element in a map is identified by its key value. + * @param Type of the mapped value. Each element in a map stores some data as its mapped value. + * + * @author Jeongho Nam + */ + abstract class MapContainer extends Container> { + /** + *

{@link List} storing elements.

+ * + *

Storing elements and keeping those sequence of the {@link MapContainer} are implemented by + * {@link data_ this list container}. Implementing index-table is also related with {@link data_ this list} + * by storing {@link ListIterator iterators} ({@link MapIterator} references {@link ListIterator}) who are + * created from {@link data_ here}.

+ */ + private data_; + /** + * Default Constructor. + */ + constructor(); + /** + * @inheritdoc + */ + assign>>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + clear(): void; + /** + *

Get iterator to element.

+ * + *

Searches the container for an element with a identifier equivalent to key and returns an + * iterator to it if found, otherwise it returns an iterator to {@link end end()}.

+ * + *

Two keys are considered equivalent if the container's comparison object returns false reflexively + * (i.e., no matter the order in which the elements are passed as arguments).

+ * + *

Another member functions, {@link has has()} and {@link count count()}, can be used to just check + * whether a particular key exists.

+ * + * @param key Key to be searched for + * @return An iterator to the element, if an element with specified key is found, or + * {@link end end()} otherwise. + */ + abstract find(key: Key): MapIterator; + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator referring the first element in the

+ * + *

Note

+ *

If the container is {@link empty}, the returned iterator is same with {@link end end()}.

+ * + * @return An iterator to the first element in the The iterator containes the first element's value. + */ + begin(): MapIterator; + /** + *

Return iterator to end.

+ *

Returns an iterator referring to the past-the-end element in the

+ * + *

The past-the-end element is the theoretical element that would follow the last element in the + * It does not point to any element, and thus shall not be dereferenced.

+ * + *

Because the ranges used by functions of the container do not include the element reference by their + * closing iterator, this function is often used in combination with {@link MapContainer}.{@link begin} to + * specify a range including all the elements in the

+ * + *

Note

+ *

Returned iterator from {@link MapContainer}.{@link end} does not refer any element. Trying to accessing + * element by the iterator will cause throwing exception ({@link OutOfRange}).

+ * + *

If the container is {@link empty}, this function returns the same as {@link begin}.

+ * + * @return An iterator to the end element in the + */ + end(): MapIterator; + /** + *

Return {@link MapReverseIterator reverse iterator} to reverse beginning.

+ * + *

Returns a {@link MapReverseIterator reverse iterator} pointing to the last element in the container + * (i.e., its reverse beginning).

+ * + * {@link MapReverseIterator Reverse iterators} iterate backwards: increasing them moves them towards the + * beginning of the container.

+ * + *

{@link rbegin} points to the element preceding the one that would be pointed to by member {@link end}. + *

+ * + * @return A {@link MapReverseIterator reverse iterator} to the reverse beginning of the sequence + * + */ + rbegin(): MapReverseIterator; + /** + *

Return {@link MapReverseIterator reverse iterator} to reverse end.

+ * + *

Returns a {@link MapReverseIterator reverse iterator} pointing to the theoretical element right before + * the first element in the {@link MapContainer map container} (which is considered its reverse end). + *

+ * + *

The range between {@link MapContainer}.{@link rbegin} and {@link MapContainer}.{@link rend} contains + * all the elements of the container (in reverse order).

+ * + * @return A {@link MapReverseIterator reverse iterator} to the reverse end of the sequence + */ + rend(): MapReverseIterator; + /** + *

Whether have the item or not.

+ * + *

Indicates whether a map has an item having the specified identifier.

+ * + * @param key Key value of the element whose mapped value is accessed. + * + * @return Whether the map has an item having the specified identifier. + */ + has(key: Key): boolean; + /** + *

Count elements with a specific key.

+ * + *

Searches the container for elements whose key is key and returns the number of elements found.

+ * + * @param key Key value to be searched for. + * + * @return The number of elements in the container with a key. + */ + abstract count(key: Key): number; + /** + * Return the number of elements in the map. + */ + size(): number; + /** + * @inheritdoc + */ + push(...args: Pair[]): number; + /** + * @inheritdoc + */ + push(...args: [Key, T][]): number; + /** + * Construct and insert element with hint + * + * Inserts a new element in the {@link MapContainer map container}. This new element is constructed in + * place using *args* as the arguments for the element's constructor. *hint* points to a location in the + * container suggested as a hint on where to start the search for its insertion point (the container may or + * may not use this suggestion to optimize the insertion operation). + * + * A similar member function exists, {@link insert}, which either copies or moves an existing object into + * the container, and may also take a position *hint*. + * + * @param hint Hint for the position where the element can be inserted. + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link MapContainer}. + */ + emplace_hint(hint: MapIterator, key: Key, val: T): MapIterator; + /** + * Construct and insert element with hint + * + * Inserts a new element in the {@link MapContainer map container}. This new element is constructed in + * place using *args* as the arguments for the element's constructor. *hint* points to a location in the + * container suggested as a hint on where to start the search for its insertion point (the container may or + * may not use this suggestion to optimize the insertion operation). + * + * A similar member function exists, {@link insert}, which either copies or moves an existing object into + * the container, and may also take a position *hint*. + * + * @param hint Hint for the position where the element can be inserted. + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return An {@link MapIterator iterator} pointing to either the newly inserted element or to the element + * that already had an equivalent key in the {@link MapContainer}. + */ + emplace_hint(hint: MapReverseIterator, key: Key, val: T): MapReverseIterator; + /** + * Construct and insert element with hint + * + * Inserts a new element in the {@link MapContainer map container}. This new element is constructed in + * place using *args* as the arguments for the element's constructor. *hint* points to a location in the + * container suggested as a hint on where to start the search for its insertion point (the container may or + * may not use this suggestion to optimize the insertion operation). + * + * A similar member function exists, {@link insert}, which either copies or moves an existing object into + * the container, and may also take a position *hint*. + * + * @param hint Hint for the position where the element can be inserted. + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link MapContainer}. + */ + emplace_hint(hint: MapIterator, pair: Pair): MapIterator; + /** + * Construct and insert element with hint + * + * Inserts a new element in the {@link MapContainer map container}. This new element is constructed in + * place using *args* as the arguments for the element's constructor. *hint* points to a location in the + * container suggested as a hint on where to start the search for its insertion point (the container may or + * may not use this suggestion to optimize the insertion operation). + * + * A similar member function exists, {@link insert}, which either copies or moves an existing object into + * the container, and may also take a position *hint*. + * + * @param hint Hint for the position where the element can be inserted. + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * + * @return An {@link MapIterator iterator} pointing to either the newly inserted element or to the element + * that already had an equivalent key in the {@link MapContainer}. + */ + emplace_hint(hint: MapReverseIterator, pair: Pair): MapReverseIterator; + /** + *

Insert an element.

+ * + *

Extends the container by inserting a new element, effectively increasing the container {@link size} + * by the number of element inserted (zero or one).

+ * + * @param hint Hint for the position where the element can be inserted. + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link MapContainer}. + */ + insert(hint: MapIterator, pair: Pair): MapIterator; + /** + *

Insert an element.

+ * + *

Extends the container by inserting a new element, effectively increasing the container {@link size} + * by the number of element inserted (zero or one).

+ * + * @param hint Hint for the position where the element can be inserted. + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link MapContainer}. + */ + insert(hint: MapReverseIterator, pair: Pair): MapReverseIterator; + /** + *

Insert an element.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} + * by the number of elements inserted.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link MapContainer}. + */ + insert(hint: MapIterator, tuple: [L, U]): MapIterator; + /** + *

Insert an element.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} + * by the number of elements inserted.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link MapContainer}. + */ + insert(hint: MapReverseIterator, tuple: [L, U]): MapReverseIterator; + /** + *

Insert elements from range iterators.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} by + * the number of elements inserted.

+ * + * @param begin Input iterator specifying initial position of a range of elements. + * @param end Input iterator specifying final position of a range of elements. + * Notice that the range includes all the elements between begin and end, + * including the element pointed by begin but not the one pointed by end. + */ + insert>>(first: InputIterator, last: InputIterator): void; + /** + * @hidden + */ + protected abstract _Insert_by_pair(pair: Pair): any; + /** + * @hidden + */ + private insert_by_tuple(tuple); + /** + * @hidden + */ + protected abstract _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; + /** + * @hidden + */ + private insert_by_hint_with_tuple(hint, tuple); + /** + * @hidden + */ + protected abstract _Insert_by_range>>(first: InputIterator, last: InputIterator): void; + /** + *

Erase an elemet by key.

+ * + *

Removes from the {@link MapContainer map container} a single element.

+ * + *

This effectively reduces the container {@link size} by the number of element removed (zero or one), + * which are destroyed.

+ * + * @param key Key of the element to be removed from the {@link MapContainer}. + */ + erase(key: Key): number; + /** + *

Erase an elemet by iterator.

+ * + *

Removes from the {@link MapContainer map container} a single element.

+ * + *

This effectively reduces the container {@link size} by the number of element removed (zero or one), + * which are destroyed.

+ * + * @param it Iterator specifying position winthin the {@link MapContainer map contaier} to be removed. + */ + erase(it: MapIterator): MapIterator; + /** + *

Erase elements by range iterators.

+ * + *

Removes from the {@link MapContainer map container} a range of elements.

+ * + *

This effectively reduces the container {@link size} by the number of elements removed, which are + * destroyed.

+ * + * @param begin An iterator specifying initial position of a range within {@link MApContainer map container} + * to be removed. + * @param end An iterator specifying initial position of a range within {@link MApContainer map container} + * to be removed. + * Notice that the range includes all the elements between begin and end, + * including the element pointed by begin but not the one pointed by end. + */ + erase(begin: MapIterator, end: MapIterator): MapIterator; + /** + *

Erase an elemet by iterator.

+ * + *

Removes from the {@link MapContainer map container} a single element.

+ * + *

This effectively reduces the container {@link size} by the number of element removed (zero or one), + * which are destroyed.

+ * + * @param it Iterator specifying position winthin the {@link MapContainer map contaier} to be removed. + */ + erase(it: MapReverseIterator): MapReverseIterator; + /** + *

Erase elements by range iterators.

+ * + *

Removes from the {@link MapContainer map container} a range of elements.

+ * + *

This effectively reduces the container {@link size} by the number of elements removed, which are + * destroyed.

+ * + * @param begin An iterator specifying initial position of a range within {@link MApContainer map container} + * to be removed. + * @param end An iterator specifying initial position of a range within {@link MApContainer map container} + * to be removed. + * Notice that the range includes all the elements between begin and end, + * including the element pointed by begin but not the one pointed by end. + */ + erase(begin: MapReverseIterator, end: MapReverseIterator): MapReverseIterator; + /** + * @hidden + */ + private erase_by_key(key); + /** + * @hidden + */ + private erase_by_iterator(first, last?); + /** + * @hidden + */ + private erase_by_range(begin, end); + /** + *

Abstract method handling insertions for indexing.

+ * + *

This method, {@link _Handle_insert} is designed to register the first to last to somewhere storing + * those {@link MapIterator iterators} for indexing, fast accessment and retrievalance.

+ * + *

When {@link insert} is called, new elements will be inserted into the {@link data_ list container} and new + * {@link MapIterator iterators} first to last, pointing the inserted elements, will be created and the + * newly created iterators first to last will be shifted into this method {@link _Handle_insert} after the + * insertions.

+ * + *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link MapIterator iterators} + * will be registered into the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the + * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be + * registered into the {@link HashSet.hash_buckets_ hash bucket}.

+ * + * @param first An {@link MapIterator} to the initial position in a sequence. + * @param last An {@link MapIterator} to the final position in a sequence. The range used is + * [first, last), which contains all the elements between first and last, + * including the element pointed by first but not the element pointed by last. + */ + protected abstract _Handle_insert(first: MapIterator, last: MapIterator): void; + /** + *

Abstract method handling deletions for indexing.

+ * + *

This method, {@link _Handle_erase} is designed to unregister the first to last to somewhere storing + * those {@link MapIterator iterators} for indexing, fast accessment and retrievalance.

+ * + *

When {@link erase} is called with first to last, {@link MapIterator iterators} positioning somewhere + * place to be deleted, is memorized and shifted to this method {@link _Handle_erase} after the deletion process is + * terminated.

+ * + *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link MapIterator iterators} + * will be unregistered from the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the + * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be + * unregistered from the {@link HashSet.hash_buckets_ hash bucket}.

+ * + * @param first An {@link MapIterator} to the initial position in a sequence. + * @param last An {@link MapIterator} to the final position in a sequence. The range used is + * [first, last), which contains all the elements between first and last, + * including the element pointed by first but not the element pointed by last. + */ + protected abstract _Handle_erase(first: MapIterator, last: MapIterator): void; + /** + * @hidden + */ + protected _Swap(obj: MapContainer): void; + } +} +declare namespace std { + /** + *

An iterator of {@link MapContainer map container}.

+ * + *

+ *

+ * + * @author Jeongho Nam + */ + class MapIterator extends Iterator> implements IComparable> { + /** + * A {@link ListIterator} pointing {@link Pair} of key and value. + */ + private list_iterator_; + /** + * Construct from the {@link MapContainer source map} and {@link ListIterator list iterator}. + * + * @param source The source {@link MapContainer}. + * @param list_iterator A {@link ListIterator} pointing {@link Pair} of key and value. + */ + constructor(source: base.MapContainer, list_iterator: ListIterator>); + /** + * Get iterator to previous element. + */ + prev(): MapIterator; + /** + * Get iterator to next element. + */ + next(): MapIterator; + /** + * Advances the Iterator by n element positions. + * + * @param step Number of element positions to advance. + * @return An advanced Iterator. + */ + advance(step: number): MapIterator; + /** + * @hidden + */ + private readonly map; + /** + * Get ListIterator. + */ + get_list_iterator(): ListIterator>; + /** + * @inheritdoc + */ + readonly value: Pair; + /** + * Get first, key element. + */ + readonly first: Key; + /** + * Get second, value element. + */ + /** + * Set second value. + */ + second: T; + /** + *

Whether an iterator is equal with the iterator.

+ * + *

Compare two iterators and returns whether they are equal or not.

+ * + * @param obj An iterator to compare + * @return Indicates whether equal or not. + */ + equal_to(obj: MapIterator): boolean; + less(obj: MapIterator): boolean; + hash(): number; + swap(obj: MapIterator): void; + } + /** + *

A reverse-iterator of {@link MapContainer map container}.

+ * + *

+ *

+ * + * @author Jeongho Nam + */ + class MapReverseIterator extends ReverseIterator, MapIterator, MapReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ + constructor(base: MapIterator); + /** + * @hidden + */ + protected create_neighbor(base: MapIterator): MapReverseIterator; + /** + * Get first, key element. + */ + readonly first: Key; + /** + * Get second, value element. + */ + /** + * Set second value. + */ + second: T; + } +} +declare namespace std.base { + /** + *

An abstract multi-map.

+ * + *

{@link MultiMap MultiMaps} are associative containers that store elements formed by a combination of a + * key value (Key) and a mapped value (T), and which allows for fast retrieval of + * individual elements based on their keys.

+ * + *

In a {@link MapContainer}, the key values are generally used to identify the elements, while the + * mapped values store the content associated to this key. The types of key and + * mapped value may differ, and are grouped together in member type value_type, which is a + * {@link Pair} type combining both:

+ * + *

typedef pair value_type;

+ * + *

{@link UniqueMap} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute position + * in the container. + *
+ * + *
Map
+ *
+ * Each element associates a key to a mapped value: + * Keys are meant to identify the elements whose main content is the mapped value. + *
+ * + *
Multiple equivalent keys
+ *
Multiple elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the keys. Each element in a map is identified by its key value. + * @param Type of the mapped value. Each element in a map stores some data as its mapped value. + * + * @author Jeongho Nam + */ + abstract class MultiMap extends MapContainer { + /** + * Construct and insert element. + * + * Inserts a new element in the {@link MultiMap}. This new element is constructed in place using args + * as the arguments for the element's constructor. + * + * This effectively increases the container {@link size} by one. + * + * A similar member function exists, {@link insert}, which either copies or moves existing objects into the + * container. + * + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return An {@link MapIterator iterator} to the newly inserted element. + */ + emplace(key: Key, value: T): MapIterator; + /** + * Construct and insert element. + * + * Inserts a new element in the {@link MultiMap}. This new element is constructed in place using args + * as the arguments for the element's constructor. + * + * This effectively increases the container {@link size} by one. + * + * A similar member function exists, {@link insert}, which either copies or moves existing objects into the + * container. + * + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * @return An {@link MapIterator iterator} to the newly inserted element. + */ + emplace(pair: Pair): MapIterator; + /** + *

Insert elements.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} by + * the number of elements inserted.

+ * + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * + * @return An iterator pointing to the newly inserted element. + */ + insert(pair: Pair): MapIterator; + /** + *

Insert elements.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} by + * the number of elements inserted.

+ * + * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. + * + * @return An iterator pointing to the newly inserted element. + */ + insert(tuple: [L, U]): MapIterator; + /** + * @inheritdoc + */ + insert(hint: MapIterator, pair: Pair): MapIterator; + /** + * @inheritdoc + */ + insert(hint: MapReverseIterator, pair: Pair): MapReverseIterator; + /** + * @inheritdoc + */ + insert(hint: MapIterator, tuple: [L, U]): MapIterator; + /** + * @inheritdoc + */ + insert(hint: MapReverseIterator, tuple: [L, U]): MapReverseIterator; + /** + * @inheritdoc + */ + insert>>(first: InputIterator, last: InputIterator): void; + } +} +declare namespace std.base { + /** + *

An abstract set.

+ * + *

{@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of + * individual elements based on their value.

+ * + *

In an {@link SetContainer}, the value of an element is at the same time its key, used to + * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be + * modified once in the container - they can be inserted and removed, though.

+ * + *

{@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
+ * + *
Set
+ *
The value of an element is also the key used to identify it.
+ *
+ * + * @param Type of the elements. Each element in a {@link SetContainer} container is also identified + * by this value (each value is itself also the element's key). + * + * @author Jeongho Nam + */ + abstract class SetContainer extends Container { + /** + *

{@link List} storing elements.

+ * + *

Storing elements and keeping those sequence of the {@link SetContainer} are implemented by + * {@link data_ this list container}. Implementing index-table is also related with {@link data_ this list} + * by storing {@link ListIterator iterators} ({@link SetIterator} references {@link ListIterator}) who are + * created from {@link data_ here}.

+ */ + private data_; + /** + * Default Constructor. + */ + constructor(); + /** + * @inheritdoc + */ + assign>(begin: Iterator, end: Iterator): void; + /** + * @inheritdoc + */ + clear(): void; + /** + *

Get iterator to element.

+ * + *

Searches the container for an element with key as value and returns an iterator to it if found, + * otherwise it returns an iterator to {@link end end()} (the element past the end of the container).

+ * + *

Another member function, {@link count count()}, can be used to just check whether a particular element + * exists.

+ * + * @param key Key to be searched for. + * + * @return An iterator to the element, if the specified value is found, or {@link end end()} if it is not + * found in the + */ + abstract find(val: T): SetIterator; + /** + * @inheritdoc + */ + begin(): SetIterator; + /** + * @inheritdoc + */ + end(): SetIterator; + /** + * @inheritdoc + */ + rbegin(): SetReverseIterator; + /** + * @inheritdoc + */ + rend(): SetReverseIterator; + /** + *

Whether have the item or not.

+ * + *

Indicates whether a set has an item having the specified identifier.

+ * + * @param key Key value of the element whose mapped value is accessed. + * + * @return Whether the set has an item having the specified identifier. + */ + has(val: T): boolean; + /** + *

Count elements with a specific key.

+ * + *

Searches the container for elements with a value of k and returns the number of elements found.

+ * + * @param key Value of the elements to be counted. + * + * @return The number of elements in the container with a key. + */ + abstract count(val: T): number; + /** + * @inheritdoc + */ + size(): number; + /** + * @inheritdoc + */ + push(...args: U[]): number; + /** + *

Insert an element with hint.

+ * + *

Extends the container by inserting new elements, effectively increasing the container size by the + * number of elements inserted.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param val Value to be inserted as an element. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had its + * same value in the {@link SetContainer}. + */ + insert(hint: SetIterator, val: T): SetIterator; + /** + *

Insert an element with hint.

+ * + *

Extends the container by inserting new elements, effectively increasing the container size by the + * number of elements inserted.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param val Value to be inserted as an element. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had its + * same value in the {@link SetContainer}. + */ + insert(hint: SetReverseIterator, val: T): SetReverseIterator; + /** + *

Insert elements with a range of a

+ * + *

Extends the container by inserting new elements, effectively increasing the container size by the + * number of elements inserted.

+ * + * @param begin An iterator specifying range of the begining element. + * @param end An iterator specifying range of the ending element. + */ + insert>(begin: InputIterator, end: InputIterator): void; + /** + * @hidden + */ + protected abstract _Insert_by_val(val: T): any; + /** + * @hidden + */ + protected abstract _Insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected abstract _Insert_by_range>(begin: InputIterator, end: InputIterator): void; + /** + *

Erase an element.

+ *

Removes from the set container the elements whose value is key.

+ * + *

This effectively reduces the container size by the number of elements removed.

+ * + * @param key Value of the elements to be erased. + * + * @return Number of elements erased. + */ + erase(val: T): number; + /** + * @inheritdoc + */ + erase(it: SetIterator): SetIterator; + /** + *

Erase elements.

+ *

Removes from the set container a range of elements..

+ * + *

This effectively reduces the container size by the number of elements removed.

+ * + * @param begin An iterator specifying a range of beginning to erase. + * @param end An iterator specifying a range of end to erase. + */ + erase(begin: SetIterator, end: SetIterator): SetIterator; + /** + * @inheritdoc + */ + erase(it: SetReverseIterator): SetReverseIterator; + /** + *

Erase elements.

+ *

Removes from the set container a range of elements..

+ * + *

This effectively reduces the container size by the number of elements removed.

+ * + * @param begin An iterator specifying a range of beginning to erase. + * @param end An iterator specifying a range of end to erase. + */ + erase(begin: SetReverseIterator, end: SetReverseIterator): SetReverseIterator; + /** + * @hidden + */ + private erase_by_iterator(first, last?); + /** + * @hidden + */ + private erase_by_val(val); + /** + * @hidden + */ + private erase_by_range(begin, end); + /** + *

Abstract method handling insertions for indexing.

+ * + *

This method, {@link _Handle_insert} is designed to register the first to last to somewhere storing + * those {@link SetIterator iterators} for indexing, fast accessment and retrievalance.

+ * + *

When {@link insert} is called, new elements will be inserted into the {@link data_ list container} and new + * {@link SetIterator iterators} first to last, pointing the inserted elements, will be created and the + * newly created iterators first to last will be shifted into this method {@link _Handle_insert} after the + * insertions.

+ * + *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link SetIterator iterators} + * will be registered into the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the + * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be + * registered into the {@link HashSet.hash_buckets_ hash bucket}.

+ * + * @param first An {@link SetIterator} to the initial position in a sequence. + * @param last An {@link SetIterator} to the final position in a sequence. The range used is + * [first, last), which contains all the elements between first and last, + * including the element pointed by first but not the element pointed by last. + */ + protected abstract _Handle_insert(first: SetIterator, last: SetIterator): void; + /** + *

Abstract method handling deletions for indexing.

+ * + *

This method, {@link _Handle_erase} is designed to unregister the first to last to somewhere storing + * those {@link SetIterator iterators} for indexing, fast accessment and retrievalance.

+ * + *

When {@link erase} is called with first to last, {@link SetIterator iterators} positioning somewhere + * place to be deleted, is memorized and shifted to this method {@link _Handle_erase} after the deletion process is + * terminated.

+ * + *

If the derived one is {@link RBTree tree-based} like {@link TreeSet}, the {@link SetIterator iterators} + * will be unregistered from the {@link TreeSet.tree_ tree} as a {@link XTreeNode tree node item}. Else if the + * derived one is {@link HashBuckets hash-based} like {@link HashSet}, the first to last will be + * unregistered from the {@link HashSet.hash_buckets_ hash bucket}.

+ * + * @param first An {@link SetIterator} to the initial position in a sequence. + * @param last An {@link SetIterator} to the final position in a sequence. The range used is + * [first, last), which contains all the elements between first and last, + * including the element pointed by first but not the element pointed by last. + */ + protected abstract _Handle_erase(first: SetIterator, last: SetIterator): void; + /** + * @hidden + */ + protected _Swap(obj: SetContainer): void; + } +} +declare namespace std { + /** + *

An iterator of a Set.

+ * + *

+ *

+ * + * @author Jeongho Nam + */ + class SetIterator extends Iterator implements IComparable> { + private list_iterator_; + /** + *

Construct from source and index number.

+ * + *

Note

+ *

Do not create iterator directly.

+ *

Use begin(), find() or end() in Map instead.

+ * + * @param map The source Set to reference. + * @param index Sequence number of the element in the source Set. + */ + constructor(source: base.SetContainer, it: ListIterator); + /** + * @inheritdoc + */ + prev(): SetIterator; + /** + * @inheritdoc + */ + next(): SetIterator; + /** + * @inheritdoc + */ + advance(size: number): SetIterator; + /** + * @hidden + */ + private readonly set; + get_list_iterator(): ListIterator; + /** + * @inheritdoc + */ + readonly value: T; + /** + * @inheritdoc + */ + equal_to(obj: SetIterator): boolean; + /** + * @inheritdoc + */ + less(obj: SetIterator): boolean; + /** + * @inheritdoc + */ + hash(): number; + /** + * @inheritdoc + */ + swap(obj: SetIterator): void; + } + /** + *

A reverse-iterator of Set.

+ * + *

+ *

+ * + * @param Type of the elements. + * + * @author Jeongho Nam + */ + class SetReverseIterator extends ReverseIterator, SetReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ + constructor(base: SetIterator); + /** + * @hidden + */ + protected create_neighbor(base: SetIterator): SetReverseIterator; + } +} +declare namespace std.base { + /** + *

An abstract set.

+ * + *

{@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of + * individual elements based on their value.

+ * + *

In an {@link SetContainer}, the value of an element is at the same time its key, used to + * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be + * modified once in the container - they can be inserted and removed, though.

+ * + *

{@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
+ * + *
Set
+ *
The value of an element is also the key used to identify it.
+ * + *
Multiple equivalent keys
+ *
Multiple elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the elements. Each element in a {@link SetContainer} container is also identified + * by this value (each value is itself also the element's key). + * + * @author Jeongho Nam + */ + abstract class MultiSet extends SetContainer { + /** + *

Insert an element.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} by + * the number of elements inserted.

+ * + * @param key Value to be inserted as an element. + * + * @return An iterator to the newly inserted element. + */ + insert(val: T): SetIterator; + /** + * @inheritdoc + */ + insert(hint: SetIterator, val: T): SetIterator; + /** + * @inheritdoc + */ + insert(hint: SetReverseIterator, val: T): SetReverseIterator; + /** + * @inheritdoc + */ + insert>(begin: InputIterator, end: InputIterator): void; + } +} declare namespace std.base { /** *

Red-black Tree.

@@ -11440,7 +6391,6 @@ declare namespace std.base { * Default Constructor. */ constructor(map: TreeMap | TreeMultiMap, compare?: (x: Key, y: Key) => boolean); - _Set_compare(val: (x: Key, y: Key) => boolean): void; find(key: Key): XTreeNode>; find(it: MapIterator): XTreeNode>; /** @@ -11741,7 +6691,6 @@ declare namespace std.base { * Default Constructor. */ constructor(set: TreeSet | TreeMultiSet, compare?: (x: T, y: T) => boolean); - _Set_compare(val: (x: T, y: T) => boolean): void; find(val: T): XTreeNode>; find(it: SetIterator): XTreeNode>; /** @@ -11866,6 +6815,427 @@ declare namespace std.base { is_less(left: SetIterator, right: SetIterator): boolean; } } +declare namespace std.base { + /** + *

An abstract unique-map.

+ * + *

{@link UniqueMap UniqueMaps} are associative containers that store elements formed by a combination of a + * key value (Key) and a mapped value (T), and which allows for fast retrieval of + * individual elements based on their keys.

+ * + *

In a {@link MapContainer}, the key values are generally used to uniquely identify the elements, + * while the mapped values store the content associated to this key. The types of key and + * mapped value may differ, and are grouped together in member type value_type, which is a + * {@link Pair} type combining both:

+ * + *

typedef pair value_type;

+ * + *

{@link UniqueMap} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute position + * in the container. + *
+ * + *
Map
+ *
+ * Each element associates a key to a mapped value: + * Keys are meant to identify the elements whose main content is the mapped value. + *
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the keys. Each element in a map is uniquely identified by its key value. + * @param Type of the mapped value. Each element in a map stores some data as its mapped value. + * + * @author Jeongho Nam + */ + abstract class UniqueMap extends MapContainer { + /** + * @inheritdoc + */ + count(key: Key): number; + /** + *

Get an element

+ * + *

Returns a reference to the mapped value of the element identified with key.

+ * + * @param key Key value of the element whose mapped value is accessed. + * + * @throw exception out of range + * + * @return A reference object of the mapped value (_Ty) + */ + get(key: Key): T; + /** + *

Set an item as the specified identifier.

+ * + *

If the identifier is already in map, change value of the identifier. If not, then insert the object + * with the identifier.

+ * + * @param key Key value of the element whose mapped value is accessed. + * @param val Value, the item. + */ + set(key: Key, val: T): void; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param key Key value of the element whose mapped value is accessed. + * + * @return A {@link Pair} containing the value pointed to by key. + */ + extract(key: Key): Pair; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: MapIterator): MapIterator; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: MapReverseIterator): MapReverseIterator; + /** + * @hidden + */ + private extract_by_key(key); + /** + * @hidden + */ + private extract_by_iterator(it); + /** + * @hidden + */ + private extract_by_reverse_iterator(it); + /** + * Construct and insert element. + * + * Inserts a new element in the {@link UniqueMap} if its *key* is unique. This new element is constructed in + * place using args as the arguments for the construction of a *value_type* (which is an object of a + * {@link Pair} type). + * + * The insertion only takes place if no other element in the container has a *key equivalent* to the one + * being emplaced (*keys* in a {@link UniqueMap} container are unique). + * + * If inserted, this effectively increases the container {@link size} by one. + * + * A similar member function exists, {@link insert}, which either copies or moves existing objects into the + * container. + * + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return If the function successfully inserts the element (because no equivalent element existed already in + * the {@link UniqueMap}), the function returns a {@link Pair} of an {@link MapIterator iterator} to + * the newly inserted element and a value of true. Otherwise, it returns an + * {@link MapIterator iterator} to the equivalent element within the container and a value of false. + */ + emplace(key: Key, value: T): Pair, boolean>; + /** + * Construct and insert element. + * + * Inserts a new element in the {@link UniqueMap} if its *key* is unique. This new element is constructed in + * place using args as the arguments for the construction of a *value_type* (which is an object of a + * {@link Pair} type). + * + * The insertion only takes place if no other element in the container has a *key equivalent* to the one + * being emplaced (*keys* in a {@link UniqueMap} container are unique). + * + * If inserted, this effectively increases the container {@link size} by one. + * + * A similar member function exists, {@link insert}, which either copies or moves existing objects into the + * container. + * + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * + * @return If the function successfully inserts the element (because no equivalent element existed already in + * the {@link UniqueMap}), the function returns a {@link Pair} of an {@link MapIterator iterator} to + * the newly inserted element and a value of true. Otherwise, it returns an + * {@link MapIterator iterator} to the equivalent element within the container and a value of false. + */ + emplace(pair: Pair): Pair, boolean>; + /** + *

Insert an element.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} by + * one.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is not inserted, returning an iterator to this existing element (if the function + * returns a value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param pair A single argument of a {@link Pair} type with a value for the *key* as + * {@link Pair.first first} member, and a *value* for the mapped value as + * {@link Pair.second second}. + * + * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly + * inserted element or to the element with an equivalent key in the {@link UniqueMap}. The + * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or + * false if an equivalent key already existed. + */ + insert(pair: Pair): Pair, boolean>; + /** + *

Insert an element.

+ * + *

Extends the container by inserting a new element, effectively increasing the container size by the + * number of elements inserted.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is not inserted, returning an iterator to this existing element (if the function + * returns a value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param tuple Tuple represensts the {@link Pair} to be inserted as an element. + * + * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly + * inserted element or to the element with an equivalent key in the {@link UniqueMap}. The + * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or + * false if an equivalent key already existed. + */ + insert(tuple: [L, U]): Pair, boolean>; + /** + * @inheritdoc + */ + insert(hint: MapIterator, pair: Pair): MapIterator; + /** + * @inheritdoc + */ + insert(hint: MapReverseIterator, pair: Pair): MapReverseIterator; + /** + * @inheritdoc + */ + insert(hint: MapIterator, tuple: [L, U]): MapIterator; + /** + * @inheritdoc + */ + insert(hint: MapReverseIterator, tuple: [L, U]): MapReverseIterator; + /** + * @inheritdoc + */ + insert>>(first: InputIterator, last: InputIterator): void; + /** + *

Insert or assign an element.

+ * + *

Inserts an element or assigns to the current element if the key already exists.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is assigned, returning an iterator to this existing element (if the function returns a + * value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly + * inserted element or to the element with an equivalent key in the {@link UniqueMap}. The + * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or + * false if an equivalent key already existed so the value is assigned. + */ + insert_or_assign(key: Key, value: T): Pair, boolean>; + /** + *

Insert or assign an element.

+ * + *

Inserts an element or assigns to the current element if the key already exists.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is assigned, returning an iterator to this existing element (if the function returns a + * value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link UniqueMap}. + */ + insert_or_assign(hint: MapIterator, key: Key, value: T): MapIterator; + /** + *

Insert or assign an element.

+ * + *

Inserts an element or assigns to the current element if the key already exists.

+ * + *

Because element keys in a {@link UniqueMap} are unique, the insertion operation checks whether + * each inserted element has a key equivalent to the one of an element already in the container, and + * if so, the element is assigned, returning an iterator to this existing element (if the function returns a + * value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiMap}.

+ * + * @param hint Hint for the position where the element can be inserted. + * @param key The key used both to look up and to insert if not found. + * @param value Value, the item. + * + * @return An iterator pointing to either the newly inserted element or to the element that already had an + * equivalent key in the {@link UniqueMap}. + */ + insert_or_assign(hint: MapReverseIterator, key: Key, value: T): MapReverseIterator; + /** + * @hidden + */ + private insert_or_assign_with_key_value(key, value); + /** + * @hidden + */ + private insert_or_assign_with_hint(hint, key, value); + } +} +declare namespace std.base { + /** + *

An abstract set.

+ * + *

{@link SetContainer SetContainers} are containers that store elements allowing fast retrieval of + * individual elements based on their value.

+ * + *

In an {@link SetContainer}, the value of an element is at the same time its key, used to uniquely + * identify it. Keys are immutable, therefore, the elements in an {@link SetContainer} cannot be modified + * once in the container - they can be inserted and removed, though.

+ * + *

{@link SetContainer} stores elements, keeps sequence and enables indexing by inserting elements into a + * {@link List} and registering {@link ListIterator iterators} of the {@link data_ list container} to an index + * table like {@link RBTree tree} or {@link HashBuckets hash-table}.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
+ * + *
Set
+ *
The value of an element is also the key used to identify it.
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the elements. Each element in a {@link SetContainer} container is also identified + * by this value (each value is itself also the element's key). + * + * @author Jeongho Nam + */ + abstract class UniqueSet extends SetContainer { + /** + * @inheritdoc + */ + count(key: T): number; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by val and erases it from the {@link UniqueSet}.

+ * + * @param val Value to be extracted. + * + * @return A value. + */ + extract(val: T): T; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetIterator): SetIterator; + /** + *

Extract an element.

+ * + *

Extracts the element pointed to by key and erases it from the {@link UniqueMap}.

+ * + * @param it An iterator pointing an element to extract. + * + * @return An iterator pointing to the element immediately following it prior to the element being + * erased. If no such element exists,returns {@link end end()}. + */ + extract(it: SetReverseIterator): SetReverseIterator; + /** + * @hidden + */ + private extract_by_key(val); + /** + * @hidden + */ + private extract_by_iterator(it); + /** + * @hidden + */ + private extract_by_reverse_iterator(it); + /** + *

Insert an element.

+ * + *

Extends the container by inserting new elements, effectively increasing the container {@link size} by + * the number of element inserted (zero or one).

+ * + *

Because elements in a {@link UniqueSet UniqueSets} are unique, the insertion operation checks whether + * each inserted element is equivalent to an element already in the container, and if so, the element is not + * inserted, returning an iterator to this existing element (if the function returns a value).

+ * + *

For a similar container allowing for duplicate elements, see {@link MultiSet}.

+ * + * @param key Value to be inserted as an element. + * + * @return A {@link Pair}, with its member {@link Pair.first} set to an iterator pointing to either the newly + * inserted element or to the equivalent element already in the {@link UniqueSet}. The + * {@link Pair.second} element in the {@link Pair} is set to true if a new element was inserted or + * false if an equivalent element already existed. + */ + insert(val: T): Pair, boolean>; + /** + * @inheritdoc + */ + insert(hint: SetIterator, val: T): SetIterator; + /** + * @inheritdoc + */ + insert(hint: SetReverseIterator, val: T): SetReverseIterator; + /** + * @inheritdoc + */ + insert>(begin: InputIterator, end: InputIterator): void; + } +} declare namespace std.base { /** *

A node in an XTree.

@@ -11906,14 +7276,4814 @@ declare namespace std.base { /** * Get grand-parent. */ - grand_parent: XTreeNode; + readonly grand_parent: XTreeNode; /** * Get sibling, opposite side node in same parent. */ - sibling: XTreeNode; + readonly sibling: XTreeNode; /** * Get uncle, parent's sibling. */ - uncle: XTreeNode; + readonly uncle: XTreeNode; + } +} +declare namespace std.Deque { + type iterator = std.DequeIterator; + type reverse_iterator = std.DequeReverseIterator; +} +declare namespace std { + /** + *

Double ended queue.

+ * + *

{@link Deque} (usually pronounced like "deck") is an irregular acronym of + * double-ended queue. Double-ended queues are sequence containers with dynamic sizes that can be + * expanded or contracted on both ends (either its front or its back).

+ * + *

Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any + * case, they allow for the individual elements to be accessed directly through random access iterators, with storage + * handled automatically by expanding and contracting the container as needed.

+ * + *

Therefore, they provide a functionality similar to vectors, but with efficient insertion and deletion of + * elements also at the beginning of the sequence, and not only at its end. But, unlike {@link Vector Vectors}, + * {@link Deque Deques} are not guaranteed to store all its elements in contiguous storage locations: accessing + * elements in a deque by offsetting a pointer to another element causes undefined behavior.

+ * + *

Both {@link Vector}s and {@link Deque}s provide a very similar interface and can be used for similar purposes, + * but internally both work in quite different ways: While {@link Vector}s use a single array that needs to be + * occasionally reallocated for growth, the elements of a {@link Deque} can be scattered in different chunks of + * storage, with the container keeping the necessary information internally to provide direct access to any of its + * elements in constant time and with a uniform sequential interface (through iterators). Therefore, + * {@link Deque Deques} are a little more complex internally than {@link Vector}s, but this allows them to grow more + * efficiently under certain circumstances, especially with very long sequences, where reallocations become more + * expensive.

+ * + *

For operations that involve frequent insertion or removals of elements at positions other than the beginning or + * the end, {@link Deque Deques} perform worse and have less consistent iterators and references than + * {@link List Lists}.

+ * + *

+ * + *

+ * + *

Container properties

+ *
+ *
Sequence
+ *
Elements in sequence containers are ordered in a strict linear sequence. Individual elements + * are accessed by their position in this sequence.
+ * + *
Dynamic array
+ *
Generally implemented as a dynamic array, it allows direct access to any element in the + * sequence and provides relatively fast addition/removal of elements at the beginning or the end + * of the sequence.
+ *
+ * + * @param Type of the elements. + * + * @reference http://www.cplusplus.com/reference/deque/deque/ + * @author Jeongho Nam + */ + class Deque extends base.Container implements base.IArrayContainer, base.IDequeContainer { + /** + * @hidden + */ + private static readonly ROW; + /** + * @hidden + */ + private static readonly MIN_CAPACITY; + /** + * @hidden + */ + private matrix_; + /** + * @hidden + */ + private size_; + /** + * @hidden + */ + private capacity_; + /** + * @hidden + */ + private get_col_size(); + /** + *

Default Constructor.

+ * + *

Constructs an empty container, with no elements.

+ */ + constructor(); + /** + *

Initializer list Constructor.

+ * + *

Constructs a container with a copy of each of the elements in array, in the same order.

+ * + * @param array An array containing elements to be copied and contained. + */ + constructor(items: Array); + /** + *

Fill Constructor.

+ * + *

Constructs a container with n elements. Each element is a copy of val (if provided).

+ * + * @param n Initial container size (i.e., the number of elements in the container at construction). + * @param val Value to fill the container with. Each of the n elements in the container is + * initialized to a copy of this value. + */ + constructor(size: number, val: T); + /** + *

Copy Constructor.

+ * + *

Constructs a container with a copy of each of the elements in container, in the same order.

+ * + * @param container Another container object of the same type (with the same class template + * arguments T), whose contents are either copied or acquired. + */ + constructor(container: Deque); + /** + *

Range Constructor.

+ * + *

Constructs a container with as many elements as the range (begin, end), with each + * element emplace-constructed from its corresponding element in that range, in the same order.

+ * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * @inheritdoc + */ + assign>(begin: InputIterator, end: InputIterator): void; + /** + * @inheritdoc + */ + assign(n: number, val: T): void; + /** + * @inheritdoc + */ + reserve(capacity: number): void; + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + begin(): DequeIterator; + /** + * @inheritdoc + */ + end(): DequeIterator; + /** + * @inheritdoc + */ + rbegin(): DequeReverseIterator; + /** + * @inheritdoc + */ + rend(): DequeReverseIterator; + /** + * @inheritdoc + */ + size(): number; + /** + * @inheritdoc + */ + empty(): boolean; + /** + * @inheritdoc + */ + capacity(): number; + /** + * @inheritdoc + */ + at(index: number): T; + /** + * @inheritdoc + */ + set(index: number, val: T): void; + /** + * @inheritdoc + */ + front(): T; + /** + * @inheritdoc + */ + back(): T; + /** + // Fetch row and column's index. + /** + * @hidden + */ + private fetch_index(index); + /** + * @inheritdoc + */ + push(...items: T[]): number; + /** + * @inheritdoc + */ + push_front(val: T): void; + /** + * @inheritdoc + */ + push_back(val: T): void; + /** + * @inheritdoc + */ + pop_front(): void; + /** + * @inheritdoc + */ + pop_back(): void; + /** + * @inheritdoc + */ + insert(position: DequeIterator, val: T): DequeIterator; + /** + * @inheritdoc + */ + insert(position: DequeIterator, n: number, val: T): DequeIterator; + /** + * @inheritdoc + */ + insert>(position: DequeIterator, begin: InputIterator, end: InputIterator): DequeIterator; + /** + * @inheritdoc + */ + insert(position: DequeReverseIterator, val: T): DequeReverseIterator; + /** + * @inheritdoc + */ + insert(position: DequeReverseIterator, n: number, val: T): DequeReverseIterator; + /** + * @inheritdoc + */ + insert>(position: DequeReverseIterator, begin: InputIterator, end: InputIterator): DequeReverseIterator; + /** + * @hidden + */ + private insert_by_val(position, val); + /** + * @hidden + */ + protected _Insert_by_repeating_val(position: DequeIterator, n: number, val: T): DequeIterator; + /** + * @hidden + */ + protected _Insert_by_range>(position: DequeIterator, begin: InputIterator, end: InputIterator): DequeIterator; + /** + * @hidden + */ + private insert_by_items(position, items); + /** + * @inheritdoc + */ + erase(position: DequeIterator): DequeIterator; + /** + * @inheritdoc + */ + erase(first: DequeIterator, last: DequeIterator): DequeIterator; + /** + * @inheritdoc + */ + erase(position: DequeReverseIterator): DequeReverseIterator; + /** + * @inheritdoc + */ + erase(first: DequeReverseIterator, last: DequeReverseIterator): DequeReverseIterator; + /** + * @hidden + */ + protected _Erase_by_range(first: DequeIterator, last: DequeIterator): DequeIterator; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link Deque container} object with same type of elements. Sizes and container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were in obj + * before the call, and the elements of obj are those which were in this. All iterators, references and + * pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link Deque container} of the same type of elements (i.e., instantiated + * with the same template parameter, T) whose content is swapped with that of this + * {@link container Deque}. + */ + swap(obj: Deque): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + } +} +declare namespace std { + /** + *

An iterator of {@link Deque}.

+ * + *

+ * + *

+ * + * @author Jeongho Nam + */ + class DequeIterator extends Iterator implements base.IArrayIterator { + /** + * Sequence number of iterator in the source {@link Deque}. + */ + private index_; + /** + *

Construct from the source {@link Deque container}.

+ * + *

Note

+ *

Do not create the iterator directly, by yourself.

+ *

Use {@link Deque.begin begin()}, {@link Deque.end end()} in {@link Deque container} instead.

+ * + * @param source The source {@link Deque container} to reference. + * @param index Sequence number of the element in the source {@link Deque}. + */ + constructor(source: Deque, index: number); + /** + * @hidden + */ + private readonly deque; + /** + * @inheritdoc + */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ + value: T; + /** + * @inheritdoc + */ + readonly index: number; + /** + * @inheritdoc + */ + prev(): DequeIterator; + /** + * @inheritdoc + */ + next(): DequeIterator; + /** + * @inheritdoc + */ + advance(n: number): DequeIterator; + /** + *

Whether an iterator is equal with the iterator.

+ * + *

Compare two iterators and returns whether they are equal or not.

+ * + *

Note

+ *

Iterator's equal_to() only compare souce container and index number.

+ * + *

Although elements in a pair, key and value are equal_to, if the source map or + * index number is different, then the {@link equal_to equal_to()} will return false. If you want to + * compare the elements of a pair, compare them directly by yourself.

+ * + * @param obj An iterator to compare + * @return Indicates whether equal or not. + */ + equal_to(obj: DequeIterator): boolean; + /** + * @inheritdoc + */ + swap(obj: DequeIterator): void; + } +} +declare namespace std { + /** + *

A reverse-iterator of Deque.

+ * + *

+ * + *

+ * + * @param Type of the elements. + * + * @author Jeongho Nam + */ + class DequeReverseIterator extends ReverseIterator, DequeReverseIterator> implements base.IArrayIterator { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ + constructor(base: DequeIterator); + /** + * @hidden + */ + protected create_neighbor(base: DequeIterator): DequeReverseIterator; + /** + * @inheritdoc + */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ + value: T; + /** + * Get index. + */ + readonly index: number; + } +} +declare namespace std { + /** + *

Function handling termination on exception

+ * + *

Calls the current terminate handler.

+ * + *

By default, the terminate handler calls abort. But this behavior can be redefined by calling + * {@link set_terminate}.

+ * + *

This function is automatically called when no catch handler can be found for a thrown exception, + * or for some other exceptional circumstance that makes impossible to continue the exception handling process.

+ * + *

This function is provided so that the terminate handler can be explicitly called by a program that needs to + * abnormally terminate, and works even if {@link set_terminate} has not been used to set a custom terminate handler + * (calling abort in this case).

+ */ + function terminate(): void; + /** + *

Set terminate handler function.

+ * + *

A terminate handler function is a function automatically called when the exception handling process has + * to be abandoned for some reason. This happens when no catch handler can be found for a thrown exception, or for + * some other exceptional circumstance that makes impossible to continue the exception handling process.

+ * + *

Before this function is called by the program for the first time, the default behavior is to call abort.

+ * + *

A program may explicitly call the current terminate handler function by calling {@link terminate}.

+ * + * @param f Function that takes no parameters and returns no value (void). + */ + function set_terminate(f: () => void): void; + /** + *

Get terminate handler function.

+ * + *

The terminate handler function is automatically called when no catch handler can be found + * for a thrown exception, or for some other exceptional circumstance that makes impossible to continue the exception + * handling process.

+ * + *

If no such function has been set by a previous call to {@link set_terminate}, the function returns a + * null-pointer.

+ * + * @return If {@link set_terminate} has previously been called by the program, the function returns the current + * terminate handler function. Otherwise, it returns a null-pointer. + */ + function get_terminate(): () => void; + /** + *

Standard exception class.

+ * + *

Base class for standard exceptions.

+ * + *

All objects thrown by components of the standard library are derived from this class. + * Therefore, all standard exceptions can be caught by catching this type by reference.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/exception/exception + * @author Jeongho Nam + */ + class Exception extends Error { + /** + * A message representing specification about the Exception. + */ + private description; + /** + * Default Constructor. + */ + constructor(); + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + /** + *

Get string identifying exception.

+ *

Returns a string that may be used to identify the exception.

+ * + *

The particular representation pointed by the returned value is implementation-defined. + * As a virtual function, derived classes may redefine this function so that specify value are + * returned.

+ */ + what(): string; + /** + * @inheritdoc + */ + readonly message: string; + /** + * @inheritdoc + */ + readonly name: string; + } + /** + *

Logic error exception.

+ * + *

This class defines the type of objects thrown as exceptions to report errors in the internal + * logical of the program, such as violation of logical preconditions or class invariants.

+ * + *

These errors are presumably detectable before the program executes.

+ * + *

It is used as a base class for several logical error exceptions.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/logic_error + * @author Jeongho Nam + */ + class LogicError extends Exception { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Domain error exception.

+ * + *

This class defines the type of objects thrown as exceptions to report domain errors.

+ * + *

Generally, the domain of a mathematical function is the subset of values that it is defined for. + * For example, the square root function is only defined for non-negative numbers. Thus, a negative number + * for such a function would qualify as a domain error.

+ * + *

No component of the standard library throws exceptions of this type. It is designed as a standard + * exception to be thrown by programs.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/domain_error + * @author Jeongho Nam + */ + class DomainError extends LogicError { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Invalid argument exception.

+ * + *

This class defines the type of objects thrown as exceptions to report an invalid argument.

+ * + *

It is a standard exception that can be thrown by programs. Some components of the standard library + * also throw exceptions of this type to signal invalid arguments.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/invalid_argument + * @author Jeongho Nam + */ + class InvalidArgument extends LogicError { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Length error exception.

+ * + *

This class defines the type of objects thrown as exceptions to report a length error.

+ * + *

It is a standard exception that can be thrown by programs. Some components of the standard library, + * such as vector and string also throw exceptions of this type to signal errors resizing.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/length_error + * @author Jeongho Nam + */ + class LengthError extends LogicError { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Out-of-range exception.

+ * + *

This class defines the type of objects thrown as exceptions to report an out-of-range error.

+ * + *

It is a standard exception that can be thrown by programs. Some components of the standard library, + * such as vector, deque, string and bitset also throw exceptions of this type to signal arguments + * out of range.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/out_of_range + * @author Jeongho Nam + */ + class OutOfRange extends LogicError { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Runtime error exception.

+ * + *

This class defines the type of objects thrown as exceptions to report errors that can only be + * detected during runtime.

+ * + *

It is used as a base class for several runtime error exceptions.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/runtime_error + * @author Jeongho Nam + */ + class RuntimeError extends Exception { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Overflow error exception.

+ * + *

This class defines the type of objects thrown as exceptions to arithmetic overflow errors.

+ * + *

It is a standard exception that can be thrown by programs. Some components of the standard library + * also throw exceptions of this type to signal range errors.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/overflow_error + * @author Jeongho Nam + */ + class OverflowError extends RuntimeError { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Underflow error exception.

+ * + *

This class defines the type of objects thrown as exceptions to arithmetic underflow errors.

+ * + *

No component of the standard library throws exceptions of this type. It is designed as a standard + * exception to be thrown by programs.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/underflow_error + * @author Jeongho Nam + */ + class UnderflowError extends RuntimeError { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } + /** + *

Range error exception.

+ * + *

This class defines the type of objects thrown as exceptions to report range errors in internal + * computations.

+ * + *

It is a standard exception that can be thrown by programs. Some components of the standard library + * also throw exceptions of this type to signal range errors.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/stdexcept/range_error + * @author Jeongho Nam + */ + class RangeError extends RuntimeError { + /** + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. + */ + constructor(message: string); + } +} +declare namespace std { + /** + *

Function object class for equality comparison.

+ * + *

Binary function object class whose call returns whether its two arguments compare equal (as returned by + * operator ==).

+ * + *

Generically, function objects are instances of a class with member function {@link IComparable.equal_to equal_to} + * defined. This member function allows the object to be used with the same syntax as a function call.

+ * + * @param x First element to compare. + * @param y Second element to compare. + * + * @return Whether the arguments are equal. + */ + function equal_to(x: T, y: T): boolean; + /** + *

Function object class for non-equality comparison.

+ * + *

Binary function object class whose call returns whether its two arguments compare not equal (as returned + * by operator operator!=).

+ * + *

Generically, function objects are instances of a class with member function {@link IComparable.equal_to equal_to} + * defined. This member function allows the object to be used with the same syntax as a function call.

+ * + * @param x First element to compare. + * @param y Second element to compare. + * + * @return Whether the arguments are not equal. + */ + function not_equal_to(x: T, y: T): boolean; + /** + *

Function for less-than inequality comparison.

+ * + *

Binary function returns whether the its first argument compares less than the second.

+ * + *

Generically, function objects are instances of a class with member function {@link IComparable.less less} + * defined. If an object doesn't have the method, then its own uid will be used to compare insteadly. + * This member function allows the object to be used with the same syntax as a function call.

+ * + *

Objects of this class can be used on standard algorithms such as {@link sort sort()}, + * {@link merge merge()} or {@link TreeMap.lower_bound lower_bound()}.

+ * + * @param Type of arguments to compare by the function call. The type shall supporrt the operation + * operator<() or method {@link IComparable.less less}. + * + * @param x First element, the standard of comparison. + * @param y Second element compare with the first. + * + * @return Whether the first parameter is less than the second. + */ + function less(x: T, y: T): boolean; + /** + *

Function object class for less-than-or-equal-to comparison.

+ * + *

Binary function object class whose call returns whether the its first argument compares {@link less less than} or + * {@link equal_to equal to} the second (as returned by operator <=).

+ * + *

Generically, function objects are instances of a class with member function {@link IComparable.less less} + * and {@link IComparable.equal_to equal_to} defined. This member function allows the object to be used with the same + * syntax as a function call.

+ * + * @param x First element, the standard of comparison. + * @param y Second element compare with the first. + * + * @return Whether the x is {@link less less than} or {@link equal_to equal to} the y. + */ + function less_equal(x: T, y: T): boolean; + /** + *

Function for greater-than inequality comparison.

+ * + *

Binary function returns whether the its first argument compares greater than the second.

+ * + *

Generically, function objects are instances of a class with member function {@link less} and + * {@link equal_to equal_to()} defined. If an object doesn't have those methods, then its own uid will be used + * to compare insteadly. This member function allows the object to be used with the same syntax as a function + * call.

+ * + *

Objects of this class can be used on standard algorithms such as {@link sort sort()}, + * {@link merge merge()} or {@link TreeMap.lower_bound lower_bound()}.

+ * + * @param Type of arguments to compare by the function call. The type shall supporrt the operation + * operator>() or method {@link IComparable.greater greater}. + * + * @return Whether the x is greater than the y. + */ + function greater(x: T, y: T): boolean; + /** + *

Function object class for greater-than-or-equal-to comparison.

+ * + *

Binary function object class whose call returns whether the its first argument compares + * {@link greater greater than} or {@link equal_to equal to} the second (as returned by operator >=).

+ * + *

Generically, function objects are instances of a class with member function {@link IComparable.less less} + * defined. If an object doesn't have the method, then its own uid will be used to compare insteadly. + * This member function allows the object to be used with the same syntax as a function call.

+ * + * @param x First element, the standard of comparison. + * @param y Second element compare with the first. + * + * @return Whether the x is {@link greater greater than} or {@link equal_to equal to} the y. + */ + function greater_equal(x: T, y: T): boolean; + /** + *

Logical AND function object class.

+ * + *

Binary function object class whose call returns the result of the logical "and" operation between its two + * arguments (as returned by operator &&).

+ * + *

Generically, function objects are instances of a class with member function operator() defined. This member + * function allows the object to be used with the same syntax as a function call.

+ * + * @param x First element. + * @param y Second element. + * + * @return Result of logical AND operation. + */ + function logical_and(x: T, y: T): boolean; + /** + *

Logical OR function object class.

+ * + *

Binary function object class whose call returns the result of the logical "or" operation between its two + * arguments (as returned by operator ||).

+ * + *

Generically, function objects are instances of a class with member function operator() defined. This member + * function allows the object to be used with the same syntax as a function call.

+ * + * @param x First element. + * @param y Second element. + * + * @return Result of logical OR operation. + */ + function logical_or(x: T, y: T): boolean; + /** + *

Logical NOT function object class.

+ * + *

Unary function object class whose call returns the result of the logical "not" operation on its argument + * (as returned by operator !).

+ * + *

Generically, function objects are instances of a class with member function operator() defined. This member + * function allows the object to be used with the same syntax as a function call.

+ * + * @param x Target element. + * + * @return Result of logical NOT operation. + */ + function logical_not(x: T): boolean; + /** + *

Bitwise AND function object class.

+ * + *

Binary function object class whose call returns the result of applying the bitwise "and" operation between + * its two arguments (as returned by operator &).

+ * + * @param x First element. + * @param y Second element. + * + * @return Result of bitwise AND operation. + */ + function bit_and(x: number, y: number): number; + /** + *

Bitwise OR function object class.

+ * + *

Binary function object class whose call returns the result of applying the bitwise "and" operation between + * its two arguments (as returned by operator &).

+ * + * @param x First element. + * @param y Second element. + * + * @return Result of bitwise OR operation. + */ + function bit_or(x: number, y: number): number; + /** + *

Bitwise XOR function object class.

+ * + *

Binary function object class whose call returns the result of applying the bitwise "exclusive or" + * operation between its two arguments (as returned by operator ^).

+ * + * @param x First element. + * @param y Second element. + * + * @return Result of bitwise XOR operation. + */ + function bit_xor(x: number, y: number): number; + /** + *

Comparable instance.

+ * + *

{@link IComparable} is a common interface for objects who can compare each other.

+ * + * @reference https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html + * @author Jeongho Nam + */ + interface IComparable extends Object { + /** + *

Indicates whether some other object is "equal to" this one.

+ * + *

The {@link equal_to} method implements an equivalence relation on non-null object references:

+ * + *
    + *
  • + * It is reflexive: for any non-null reference value x, x.equal_to(x) + * should return true. + *
  • + *
  • + * It is symmetric: for any non-null reference values x and y, + * x.equal_to(y) should return true if and only if y.equal_to(x) + * returns true.
  • + *
  • + * It is transitive: for any non-null reference values x, y, and + * z, if x.equal_to(y) returns true and y.equal_to(z) + * returns true, then x.equal_to(z) should return true. + *
  • + *
  • + * It is consistent: for any non-null reference values x and y, multiple + * invocations of x.equal_to(y) consistently return true or consistently return + * false, provided no information used in equal_to comparisons on the objects is modified. + *
  • + *
  • + * For any non-null reference value x, x.equal_to(null) should return + * false. + *
  • + *
+ * + *

The {@link equal_to} method for interface {@link IComparable} implements the most discriminating possible + * equivalence relation on objects; that is, for any non-null reference values x and + * y, this method returns true if and only if x and y + * refer to the same object (x == y has the value true).

+ * + *

Note that it is generally necessary to override the {@link hash_code} method whenever this method is + * overridden, so as to maintain the general contract for the {@link hash_code} method, which states that + * equal objects must have equal hash codes.

+ * + *
    + *
  • {@link IComparable.equal_to} is called by {@link std.equal_to}.
  • + *
+ * + * @param obj the reference object with which to compare. + * + * @return true if this object is the same as the obj argument; false otherwise. + */ + equal_to(obj: T): boolean; + /** + *

Less-than inequality comparison.

+ * + *

Binary method returns whether the the instance compares less than the obj.

+ * + *
    + *
  • + * {@link IComparable.less} is called by {@link std.less}. Also, this method can be used on standard + * algorithms such as {@link sort sort()}, {@link merge merge()} or + * {@link TreeMap.lower_bound lower_bound()}. + *
  • + *
+ * + * @param obj the reference object with which to compare. + * + * @return Whether the first parameter is less than the second. + */ + less(obj: T): boolean; + /** + *

Issue a hash code.

+ * + *

Returns a hash code value for the object. This method is supported for the benefit of hash tables such + * as those provided by hash containers; {@link HashSet}, {@link HashMap}, {@link MultiHashSet} and + * {@link MultiHashMap}.

+ * + *

As much as is reasonably practical, the {@link hash_code} method defined by interface + * {@link IComparable} does return distinct integers for distinct objects. (This is typically implemented by + * converting the internal address of the object into an integer, but this implementation technique is not + * required by the JavaScript programming language.)

+ * + *
    + *
  • + * {@link IComparable.hash_code} is called by {@link std.hash_code}. If you want to keep basically + * provided hash function, then returns {@link std.Hash.code}; return std.Hash.code(this); + *
  • + *
+ * + * @return An hash code who represents the object. + */ + hash(): number; + } + /** + *

Default hash function for number.

+ * + *

Unary function that defines the default hash function used by the standard library.

+ * + *

The functional call returns a hash value of its argument: A hash value is a value that depends solely on + * its argument, returning always the same value for the same argument (for a given execution of a program). The + * value returned shall have a small likelihood of being the same as the one returned for a different argument. + *

+ * + * @param val Value to be hashed. + * + * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. + */ + function hash(val: number): number; + /** + *

Default hash function for string.

+ * + *

Unary function that defines the default hash function used by the standard library.

+ * + *

The functional call returns a hash value of its argument: A hash value is a value that depends solely on + * its argument, returning always the same value for the same argument (for a given execution of a program). The + * value returned shall have a small likelihood of being the same as the one returned for a different argument. + *

+ * + * @param str A string to be hashed. + * + * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. + */ + function hash(str: string): number; + /** + *

Default hash function for Object.

+ * + *

Unary function that defines the default hash function used by the standard library.

+ * + *

The functional call returns a hash value of its argument: A hash value is a value that depends solely on + * its argument, returning always the same value for the same argument (for a given execution of a program). The + * value returned shall have a small likelihood of being the same as the one returned for a different argument. + *

+ * + *

The default {@link hash} function of Object returns a value returned from {@link hash hash(number)} with + * an unique id of each Object. If you want to specify {@link hash} function of a specific class, then + * define a member function public hash(): number in the class.

+ * + * @param obj Object to be hashed. + * + * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. + */ + function hash(obj: Object): number; + /** + *

Exchange contents of {@link IContainers containers}.

+ * + *

The contents of container left are exchanged with those of right. Both container objects must have + * same type of elements (same template parameters), although sizes may differ.

+ * + *

After the call to this member function, the elements in left are those which were in right before + * the call, and the elements of right are those which were in left. All iterators, references and + * pointers remain valid for the swapped objects.

+ * + *

This is an overload of the generic algorithm swap that improves its performance by mutually transferring + * ownership over their assets to the other container (i.e., the containers exchange references to their data, without + * actually performing any element copy or movement): It behaves as if left. + * {@link IContainer.swap swap}(right) was called.

+ * + * @param left A {@link IContainer container} to swap its contents. + * @param right A {@link IContainer container} to swap its contents. + */ + function swap(left: base.IContainer, right: base.IContainer): void; + /** + *

Exchange contents of queues.

+ * + *

Exchanges the contents of left and right.

+ * + * @param left A {@link Queue} container of the same type. Size may differ. + * @param right A {@link Queue} container of the same type. Size may differ. + */ + function swap(left: Queue, right: Queue): void; + /** + *

Exchange contents of {@link PriorityQueue PriorityQueues}.

+ * + *

Exchanges the contents of left and right.

+ * + * @param left A {@link PriorityQueue} container of the same type. Size may differ. + * @param right A {@link PriorityQueue} container of the same type. Size may differ. + */ + function swap(left: PriorityQueue, right: PriorityQueue): void; + /** + *

Exchange contents of {@link Stack Stacks}.

+ * + *

Exchanges the contents of left and right.

+ * + * @param left A {@link Stack} container of the same type. Size may differ. + * @param right A {@link Stack} container of the same type. Size may differ. + */ + function swap(left: Stack, right: Stack): void; + /** + *

Exchanges the contents of two {@link UniqueMap unique maps}.

+ * + *

The contents of container left are exchanged with those of right. Both container objects must + * be of the same type (same template parameters), although sizes may differ.

+ * + *

After the call to this member function, the elements in left are those which were in right + * before the call, and the elements of right are those which were in left. All iterators, references + * and pointers remain valid for the swapped objects.

+ * + *

This is an overload of the generic algorithm swap that improves its performance by mutually transferring + * ownership over their assets to the other container (i.e., the containers exchange references to their data, + * without actually performing any element copy or movement): It behaves as if + * left.{@link UniqueMap.swap swap}(right) was called.

+ * + * @param left An {@link UniqueMap unique map} to swap its conents. + * @param right An {@link UniqueMap unique map} to swap its conents. + */ + function swap(left: base.UniqueMap, right: base.UniqueMap): void; + /** + *

Exchanges the contents of two {@link MultiMap multi maps}.

+ * + *

The contents of container left are exchanged with those of right. Both container objects must + * be of the same type (same template parameters), although sizes may differ.

+ * + *

After the call to this member function, the elements in left are those which were in right + * before the call, and the elements of right are those which were in left. All iterators, references + * and pointers remain valid for the swapped objects.

+ * + *

This is an overload of the generic algorithm swap that improves its performance by mutually transferring + * ownership over their assets to the other container (i.e., the containers exchange references to their data, + * without actually performing any element copy or movement): It behaves as if + * left.{@link MultiMap.swap swap}(right) was called.

+ * + * @param left A {@link MultiMap multi map} to swap its conents. + * @param right A {@link MultiMap multi map} to swap its conents. + */ + function swap(left: base.MultiMap, right: base.MultiMap): void; +} +declare namespace std { + /** + *

Bind function arguments.

+ * + *

Returns a function object based on fn, but with its arguments bound to args.

+ * + *

Each argument may either be bound to a value or be a {@link placeholders placeholder}:

+ *
    + *
  • If bound to a value, calling the returned function object will always use that value as argument.
  • + *
  • + * If a {@link placeholders placeholder}, calling the returned function object forwards an argument passed to the + * call (the one whose order number is specified by the placeholder). + *
  • + *
+ * + *

Calling the returned object returns the same type as fn.

+ * + * @param fn A function object, pointer to function or pointer to member. + * @param args List of arguments to bind: either values, or {@link placeholders}. + * + * @return A function object that, when called, calls fn with its arguments bound to args. If fn is + * a pointer to member, the first argument expected by the returned function is an object of the class fn + * is a member. + */ + function bind(fn: (...args: any[]) => Ret, ...args: any[]): (...args: any[]) => Ret; + /** + *

Bind function arguments.

+ * + *

Returns a function object based on fn, but with its arguments bound to args.

+ * + *

Each argument may either be bound to a value or be a {@link placeholders placeholder}:

+ *
    + *
  • If bound to a value, calling the returned function object will always use that value as argument.
  • + *
  • + * If a {@link placeholders placeholder}, calling the returned function object forwards an argument passed to the + * call (the one whose order number is specified by the placeholder). + *
  • + *
+ * + *

Calling the returned object returns the same type as fn.

+ * + * @param fn A function object, pointer to function or pointer to member. + * @param thisArg This argument, owner object of the member method fn. + * @param args List of arguments to bind: either values, or {@link placeholders}. + * + * @return A function object that, when called, calls fn with its arguments bound to args. If fn is + * a pointer to member, the first argument expected by the returned function is an object of the class fn + * is a member. + */ + function bind(fn: (...args: any[]) => Ret, thisArg: T, ...args: any[]): (...args: any[]) => Ret; +} +/** + *

Bind argument placeholders.

+ * + *
+ * + *

When the function object returned by bind is called, an argument with placeholder {@link _1} is replaced by the + * first argument in the call, {@link _2} is replaced by the second argument in the call, and so on... For example:

+ * + * + * let vec: Vector = new Vector(); + * + * let bind = std.bind(Vector.insert, _1, vec.end(), _2, _3); + * bind.apply(vec, 5, 1); // vec.insert(vec.end(), 5, 1); + * // [1, 1, 1, 1, 1] + * + * + *

When a call to {@link bind} is used as a subexpression in another call to bind, the {@link placeholders} + * are relative to the outermost {@link bind} expression.

+ * + * @reference http://www.cplusplus.com/reference/functional/placeholders/ + * @author Jeongho Nam + */ +declare namespace std.placeholders { + /** + * @hidden + */ + class PlaceHolder { + private index_; + constructor(index: number); + readonly index: number; + } + /** + * Replaced by the first argument in the function call. + */ + const _1: PlaceHolder; + /** + * Replaced by the second argument in the function call. + */ + const _2: PlaceHolder; + /** + * Replaced by the third argument in the function call. + */ + const _3: PlaceHolder; + const _4: PlaceHolder; + const _5: PlaceHolder; + const _6: PlaceHolder; + const _7: PlaceHolder; + const _8: PlaceHolder; + const _9: PlaceHolder; + const _10: PlaceHolder; + const _11: PlaceHolder; + const _12: PlaceHolder; + const _13: PlaceHolder; + const _14: PlaceHolder; + const _15: PlaceHolder; + const _16: PlaceHolder; + const _17: PlaceHolder; + const _18: PlaceHolder; + const _19: PlaceHolder; + const _20: PlaceHolder; +} +declare namespace std.HashMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} +declare namespace std { + /** + *

Hashed, unordered map.

+ * + *

{@link HashMap}s are associative containers that store elements formed by the combination of a key value + * and a mapped value, and which allows for fast retrieval of individual elements based on their keys. + *

+ * + *

In an {@link HashMap}, the key value is generally used to uniquely identify the element, while the + * mapped value is an object with the content associated to this key. Types of key and + * mapped value may differ.

+ * + *

Internally, the elements in the {@link HashMap} are not sorted in any particular order with respect to either + * their key or mapped values, but organized into buckets depending on their hash values to allow + * for fast access to individual elements directly by their key values (with a constant average time complexity + * on average).

+ * + *

{@link HashMap} containers are faster than {@link TreeMap} containers to access individual elements by their + * key, although they are generally less efficient for range iteration through a subset of their elements.

+ * + *

+ * + *

+ * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their key.
+ * + *
Map
+ *
Each element associates a key to a mapped value: + * Keys are meant to identify the elements whose main content is the mapped value.
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the key values. + * Each element in an {@link HashMap} is uniquely identified by its key value. + * @param Type of the mapped value. + * Each element in an {@link HashMap} is used to store some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/unordered_map/unordered_map + * @author Jeongho Nam + */ + class HashMap extends base.UniqueMap implements base.IHashMap { + /** + * @hidden + */ + private hash_buckets_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from elements. + */ + constructor(items: Pair[]); + /** + * Contruct from tuples. + * + * @param array Tuples to be contained. + */ + constructor(array: [Key, T][]); + /** + * Copy Constructor. + */ + constructor(container: HashMap); + /** + * Construct from range iterators. + */ + constructor(begin: Iterator>, end: Iterator>); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: Key): MapIterator; + /** + * @inheritdoc + */ + begin(): MapIterator; + /** + * @inheritdoc + */ + begin(index: number): MapIterator; + /** + * @inheritdoc + */ + end(): MapIterator; + /** + * @inheritdoc + */ + end(index: number): MapIterator; + /** + * @inheritdoc + */ + rbegin(): MapReverseIterator; + /** + * @inheritdoc + */ + rbegin(index: number): MapReverseIterator; + /** + * @inheritdoc + */ + rend(): MapReverseIterator; + /** + * @inheritdoc + */ + rend(index: number): MapReverseIterator; + /** + * @inheritdoc + */ + bucket_count(): number; + /** + * @inheritdoc + */ + bucket_size(index: number): number; + /** + * @inheritdoc + */ + max_load_factor(): number; + /** + * @inheritdoc + */ + max_load_factor(z: number): void; + /** + * @inheritdoc + */ + bucket(key: Key): number; + /** + * @inheritdoc + */ + reserve(n: number): void; + /** + * @inheritdoc + */ + rehash(n: number): void; + /** + * @hidden + */ + protected _Insert_by_pair(pair: Pair): any; + /** + * @hidden + */ + protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; + /** + * @hidden + */ + protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: MapIterator, last: MapIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: MapIterator, last: MapIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link HashMap map} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link HashMap map container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link HashMap container}. + */ + swap(obj: HashMap): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer>): void; + } +} +declare namespace std.HashMultiMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} +declare namespace std { + /** + *

Hashed, unordered Multimap.

+ * + *

{@link HashMultiMap}s are associative containers that store elements formed by the combination of + * a key value and a mapped value, much like {@link HashMultiMap} containers, but allowing + * different elements to have equivalent keys.

+ * + *

In an {@link HashMultiMap}, the key value is generally used to uniquely identify the + * element, while the mapped value is an object with the content associated to this key. + * Types of key and mapped value may differ.

+ * + *

Internally, the elements in the {@link HashMultiMap} are not sorted in any particular order with + * respect to either their key or mapped values, but organized into buckets depending on + * their hash values to allow for fast access to individual elements directly by their key values + * (with a constant average time complexity on average).

+ * + *

Elements with equivalent keys are grouped together in the same bucket and in such a way that + * an iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

+ * + *

+ * + *

+ * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their key.
+ * + *
Map
+ *
Each element associates a key to a mapped value: + * Keys are meant to identify the elements whose main content is the mapped value.
+ * + *
Multiple equivalent keys
+ *
The container can hold multiple elements with equivalent keys.
+ *
+ * + * @param Type of the key values. + * Each element in an {@link HashMultiMap} is identified by a key value. + * @param Type of the mapped value. + * Each element in an {@link HashMultiMap} is used to store some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/unordered_map/unordered_multimap + * @author Jeongho Nam + */ + class HashMultiMap extends base.MultiMap { + /** + * @hidden + */ + private hash_buckets_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from elements. + */ + constructor(items: Pair[]); + /** + * Contruct from tuples. + * + * @param array Tuples to be contained. + */ + constructor(array: [Key, T][]); + /** + * Copy Constructor. + */ + constructor(container: HashMultiMap); + /** + * Construct from range iterators. + */ + constructor(begin: Iterator>, end: Iterator>); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: Key): MapIterator; + /** + * @inheritdoc + */ + count(key: Key): number; + /** + * @inheritdoc + */ + begin(): MapIterator; + /** + * @inheritdoc + */ + begin(index: number): MapIterator; + /** + * @inheritdoc + */ + end(): MapIterator; + /** + * @inheritdoc + */ + end(index: number): MapIterator; + /** + * @inheritdoc + */ + rbegin(): MapReverseIterator; + /** + * @inheritdoc + */ + rbegin(index: number): MapReverseIterator; + /** + * @inheritdoc + */ + rend(): MapReverseIterator; + /** + * @inheritdoc + */ + rend(index: number): MapReverseIterator; + /** + * @inheritdoc + */ + bucket_count(): number; + /** + * @inheritdoc + */ + bucket_size(n: number): number; + /** + * @inheritdoc + */ + max_load_factor(): number; + /** + * @inheritdoc + */ + max_load_factor(z: number): void; + /** + * @inheritdoc + */ + bucket(key: Key): number; + /** + * @inheritdoc + */ + reserve(n: number): void; + /** + * @inheritdoc + */ + rehash(n: number): void; + /** + * @hidden + */ + protected _Insert_by_pair(pair: Pair): any; + /** + * @hidden + */ + protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; + /** + * @hidden + */ + protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: MapIterator, last: MapIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: MapIterator, last: MapIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link HashMultiMap map} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link HashMultiMap map container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link HashMultiMap container}. + */ + swap(obj: HashMultiMap): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer>): void; + } +} +declare namespace std.HashMultiSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

Hashed, unordered Multiset.

+ * + *

{@link HashMultiSet HashMultiSets} are containers that store elements in no particular order, allowing fast + * retrieval of individual elements based on their value, much like {@link HashMultiSet} containers, + * but allowing different elements to have equivalent values.

+ * + *

In an {@link HashMultiSet}, the value of an element is at the same time its key, used to + * identify it. Keys are immutable, therefore, the elements in an {@link HashMultiSet} cannot be + * modified once in the container - they can be inserted and removed, though.

+ * + *

Internally, the elements in the {@link HashMultiSet} are not sorted in any particular, but + * organized into buckets depending on their hash values to allow for fast access to individual + * elements directly by their values (with a constant average time complexity on average).

+ * + *

Elements with equivalent values are grouped together in the same bucket and in such a way that an + * iterator can iterate through all of them. Iterators in the container are doubly linked iterators.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their key.
+ * + *
Set
+ *
The value of an element is also the key used to identify it.
+ * + *
Multiple equivalent keys
+ *
The container can hold multiple elements with equivalent keys.
+ *
+ * + * @param Type of the elements. + * Each element in an {@link UnorderedMultiSet} is also identified by this value.. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_multiset + * @author Jeongho Nam + */ + class HashMultiSet extends base.MultiSet { + /** + * @hidden + */ + private hash_buckets_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from elements. + */ + constructor(items: T[]); + /** + * Copy Constructor. + */ + constructor(container: HashMultiSet); + /** + * Construct from range iterators. + */ + constructor(begin: Iterator, end: Iterator); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: T): SetIterator; + /** + * @inheritdoc + */ + count(key: T): number; + /** + * @inheritdoc + */ + begin(): SetIterator; + /** + * @inheritdoc + */ + begin(index: number): SetIterator; + /** + * @inheritdoc + */ + end(): SetIterator; + /** + * @inheritdoc + */ + end(index: number): SetIterator; + /** + * @inheritdoc + */ + rbegin(): SetReverseIterator; + /** + * @inheritdoc + */ + rbegin(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + rend(): SetReverseIterator; + /** + * @inheritdoc + */ + rend(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + bucket_count(): number; + /** + * @inheritdoc + */ + bucket_size(n: number): number; + /** + * @inheritdoc + */ + max_load_factor(): number; + /** + * @inheritdoc + */ + max_load_factor(z: number): void; + /** + * @inheritdoc + */ + bucket(key: T): number; + /** + * @inheritdoc + */ + reserve(n: number): void; + /** + * @inheritdoc + */ + rehash(n: number): void; + /** + * @hidden + */ + protected _Insert_by_val(val: T): any; + /** + * @hidden + */ + protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: SetIterator, last: SetIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link HashMultiSet set} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link HashMultiSet set container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link HashMultiSet container}. + */ + swap(obj: HashMultiSet): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + } +} +declare namespace std.HashSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

Hashed, unordered set.

+ * + *

{@link HashSet}s are containers that store unique elements in no particular order, and which + * allow for fast retrieval of individual elements based on their value.

+ * + *

In an {@link HashSet}, the value of an element is at the same time its key, that + * identifies it uniquely. Keys are immutable, therefore, the elements in an {@link HashSet} cannot be + * modified once in the container - they can be inserted and removed, though.

+ * + *

Internally, the elements in the {@link HashSet} are not sorted in any particular order, but + * organized into buckets depending on their hash values to allow for fast access to individual elements + * directly by their values (with a constant average time complexity on average).

+ * + *

{@link HashSet} containers are faster than {@link TreeSet} containers to access individual + * elements by their key, although they are generally less efficient for range iteration through a + * subset of their elements.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
+ * + *
Hashed
+ *
Hashed containers organize their elements using hash tables that allow for fast access to elements + * by their key.
+ * + *
Set
+ *
The value of an element is also the key used to identify it.
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the elements. + * Each element in an {@link HashSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set + * @author Jeongho Nam + */ + class HashSet extends base.UniqueSet implements base.IHashSet { + /** + * @hidden + */ + private hash_buckets_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from elements. + */ + constructor(items: T[]); + /** + * Copy Constructor. + */ + constructor(container: HashSet); + /** + * Construct from range iterators. + */ + constructor(begin: Iterator, end: Iterator); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: T): SetIterator; + /** + * @inheritdoc + */ + begin(): SetIterator; + /** + * @inheritdoc + */ + begin(index: number): SetIterator; + /** + * @inheritdoc + */ + end(): SetIterator; + /** + * @inheritdoc + */ + end(index: number): SetIterator; + /** + * @inheritdoc + */ + rbegin(): SetReverseIterator; + /** + * @inheritdoc + */ + rbegin(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + rend(): SetReverseIterator; + /** + * @inheritdoc + */ + rend(index: number): SetReverseIterator; + /** + * @inheritdoc + */ + bucket_count(): number; + /** + * @inheritdoc + */ + bucket_size(n: number): number; + /** + * @inheritdoc + */ + max_load_factor(): number; + /** + * @inheritdoc + */ + max_load_factor(z: number): void; + /** + * @inheritdoc + */ + bucket(key: T): number; + /** + * @inheritdoc + */ + reserve(n: number): void; + /** + * @inheritdoc + */ + rehash(n: number): void; + /** + * @hidden + */ + protected _Insert_by_val(val: T): any; + /** + * @hidden + */ + protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: SetIterator, last: SetIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link HashSet set} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link HashSet set container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link HashSet container}. + */ + swap(obj: HashSet): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + } +} +declare namespace std.List { + type iterator = std.ListIterator; + type reverse_iterator = std.ListReverseIterator; +} +declare namespace std { + /** + *

Doubly linked list.

+ * + *

{@link List}s are sequence containers that allow constant time insert and erase operations anywhere within the + * sequence, and iteration in both directions.

+ * + *

List containers are implemented as doubly-linked lists; Doubly linked lists can store each of the elements they + * contain in different and unrelated storage locations. The ordering is kept internally by the association to each + * element of a link to the element preceding it and a link to the element following it.

+ * + *

They are very similar to forward_list: The main difference being that forward_list objects are single-linked + * lists, and thus they can only be iterated forwards, in exchange for being somewhat smaller and more efficient.

+ * + *

Compared to other base standard sequence containers (array, vector and deque), lists perform generally better + * in inserting, extracting and moving elements in any position within the container for which an iterator has already + * been obtained, and therefore also in algorithms that make intensive use of these, like sorting algorithms.

+ * + *

The main drawback of lists and forward_lists compared to these other sequence containers is that they lack + * direct access to the elements by their position; For example, to access the sixth element in a list, one has to + * iterate from a known position (like the beginning or the end) to that position, which takes linear time in the + * distance between these. They also consume some extra memory to keep the linking information associated to each + * element (which may be an important factor for large lists of small-sized elements).

+ * + *

+ * + *

+ * + *

Container properties

+ *
+ *
Sequence
+ *
Elements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by + * their position in this sequence.
+ * + *
Doubly-linked list
+ *
Each element keeps information on how to locate the next and the previous elements, allowing constant time + * insert and erase operations before or after a specific element (even of entire ranges), but no direct random + * access.
+ *
+ * + * @param Type of the elements. + * + * @reference http://www.cplusplus.com/reference/list/list/ + * @author Jeongho Nam + */ + class List extends base.Container implements base.IDequeContainer { + /** + * @hidden + */ + private begin_; + /** + * @hidden + */ + private end_; + /** + * @hidden + */ + private size_; + /** + *

Default Constructor.

+ * + *

Constructs an empty container, with no elements.

+ */ + constructor(); + /** + *

Initializer list Constructor.

+ * + *

Constructs a container with a copy of each of the elements in array, in the same order.

+ * + * @param array An array containing elements to be copied and contained. + */ + constructor(items: Array); + /** + *

Fill Constructor.

+ * + *

Constructs a container with n elements. Each element is a copy of val (if provided).

+ * + * @param n Initial container size (i.e., the number of elements in the container at construction). + * @param val Value to fill the container with. Each of the n elements in the container is + * initialized to a copy of this value. + */ + constructor(size: number, val: T); + /** + *

Copy Constructor.

+ * + *

Constructs a container with a copy of each of the elements in container, in the same order.

+ * + * @param container Another container object of the same type (with the same class template + * arguments T), whose contents are either copied or acquired. + */ + constructor(container: List); + /** + *

Range Constructor.

+ * + *

Constructs a container with as many elements as the range (begin, end), with each + * element emplace-constructed from its corresponding element in that range, in the same order.

+ * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * @inheritdoc + */ + assign(n: number, val: T): void; + /** + * @inheritdoc + */ + assign>(begin: InputIterator, end: InputIterator): void; + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + begin(): ListIterator; + /** + * @inheritdoc + */ + end(): ListIterator; + /** + * @inheritdoc + */ + rbegin(): ListReverseIterator; + /** + * @inheritdoc + */ + rend(): ListReverseIterator; + /** + * @inheritdoc + */ + size(): number; + /** + * @inheritdoc + */ + front(): T; + /** + * @inheritdoc + */ + back(): T; + /** + * @inheritdoc + */ + push(...items: U[]): number; + /** + * @inheritdoc + */ + push_front(val: T): void; + /** + * @inheritdoc + */ + push_back(val: T): void; + /** + * @inheritdoc + */ + pop_front(): void; + /** + * @inheritdoc + */ + pop_back(): void; + /** + *

Insert an element.

+ * + *

The container is extended by inserting a new element before the element at the specified + * position. This effectively increases the {@link List.size List size} by the amount of elements + * inserted.

+ * + *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient + * inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Position in the container where the new element is inserted. + * {@link iterator}> is a member type, defined as a + * {@link ListIterator bidirectional iterator} type that points to elements. + * @param val Value to be inserted as an element. + * + * @return An iterator that points to the newly inserted element; val. + */ + insert(position: ListIterator, val: T): ListIterator; + /** + *

Insert elements by repeated filling.

+ * + *

The container is extended by inserting a new element before the element at the specified + * position. This effectively increases the {@link List.size List size} by the amount of elements + * inserted.

+ * + *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient + * inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Position in the container where the new elements are inserted. The {@link iterator} is a + * member type, defined as a {@link ListIterator bidirectional iterator} type that points to + * elements. + * @param size Number of elements to insert. + * @param val Value to be inserted as an element. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert(position: ListIterator, size: number, val: T): ListIterator; + /** + *

Insert elements by range iterators.

+ * + *

The container is extended by inserting a new element before the element at the specified + * position. This effectively increases the {@link List.size List size} by the amount of elements + * inserted.

+ * + *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient + * inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Position in the container where the new elements are inserted. The {@link iterator} is a + * member type, defined as a {@link ListIterator bidirectional iterator} type that points to + * elements. + * @param begin An iterator specifying range of the begining element. + * @param end An iterator specifying range of the ending element. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert>(position: ListIterator, begin: InputIterator, end: InputIterator): ListIterator; + /** + *

Insert an element.

+ * + *

The container is extended by inserting a new element before the element at the specified + * position. This effectively increases the {@link List.size List size} by the amount of elements + * inserted.

+ * + *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient + * inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Position in the container where the new element is inserted. + * {@link iterator}> is a member type, defined as a + * {@link ListReverseIterator bidirectional iterator} type that points to elements. + * @param val Value to be inserted as an element. + * + * @return An iterator that points to the newly inserted element; val. + */ + insert(position: ListReverseIterator, val: T): ListReverseIterator; + /** + *

Insert elements by repeated filling.

+ * + *

The container is extended by inserting a new element before the element at the specified + * position. This effectively increases the {@link List.size List size} by the amount of elements + * inserted.

+ * + *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient + * inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Position in the container where the new elements are inserted. The {@link iterator} is a + * member type, defined as a {@link ListReverseIterator bidirectional iterator} type that points to + * elements. + * @param size Number of elements to insert. + * @param val Value to be inserted as an element. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert(position: ListReverseIterator, size: number, val: T): ListReverseIterator; + /** + *

Insert elements by range iterators.

+ * + *

The container is extended by inserting a new element before the element at the specified + * position. This effectively increases the {@link List.size List size} by the amount of elements + * inserted.

+ * + *

Unlike other standard sequence containers, {@link List} is specifically designed to be efficient + * inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Position in the container where the new elements are inserted. The {@link iterator} is a + * member type, defined as a {@link ListReverseIterator bidirectional iterator} type that points to + * elements. + * @param begin An iterator specifying range of the begining element. + * @param end An iterator specifying range of the ending element. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert>(position: ListReverseIterator, begin: InputIterator, end: InputIterator): ListReverseIterator; + /** + * @hidden + */ + private insert_by_val(position, val); + /** + * @hidden + */ + protected _Insert_by_repeating_val(position: ListIterator, size: number, val: T): ListIterator; + /** + * @hidden + */ + protected _Insert_by_range>(position: ListIterator, begin: InputIterator, end: InputIterator): ListIterator; + /** + *

Erase an element.

+ * + *

Removes from the {@link List} either a single element; position.

+ * + *

This effectively reduces the container size by the number of element removed.

+ * + *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be + * efficient inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Iterator pointing to a single element to be removed from the {@link List}. + * + * @return An iterator pointing to the element that followed the last element erased by the function call. + * This is the {@link end end()} if the operation erased the last element in the sequence. + */ + erase(position: ListIterator): ListIterator; + /** + *

Erase elements.

+ * + *

Removes from the {@link List} container a range of elements.

+ * + *

This effectively reduces the container {@link size} by the number of elements removed.

+ * + *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be + * efficient inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param begin An iterator specifying a range of beginning to erase. + * @param end An iterator specifying a range of end to erase. + * + * @return An iterator pointing to the element that followed the last element erased by the function call. + * This is the {@link end end()} if the operation erased the last element in the sequence. + */ + erase(begin: ListIterator, end: ListIterator): ListIterator; + /** + *

Erase an element.

+ * + *

Removes from the {@link List} either a single element; position.

+ * + *

This effectively reduces the container size by the number of element removed.

+ * + *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be + * efficient inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param position Iterator pointing to a single element to be removed from the {@link List}. + * + * @return An iterator pointing to the element that followed the last element erased by the function call. + * This is the {@link rend rend()} if the operation erased the last element in the sequence. + */ + erase(position: ListReverseIterator): ListReverseIterator; + /** + *

Erase elements.

+ * + *

Removes from the {@link List} container a range of elements.

+ * + *

This effectively reduces the container {@link size} by the number of elements removed.

+ * + *

Unlike other standard sequence containers, {@link List} objects are specifically designed to be + * efficient inserting and removing elements in any position, even in the middle of the sequence.

+ * + * @param begin An iterator specifying a range of beginning to erase. + * @param end An iterator specifying a range of end to erase. + * + * @return An iterator pointing to the element that followed the last element erased by the function call. + * This is the {@link rend rend()} if the operation erased the last element in the sequence. + */ + erase(begin: ListReverseIterator, end: ListReverseIterator): ListReverseIterator; + /** + * @hidden + */ + protected _Erase_by_range(first: ListIterator, last: ListIterator): ListIterator; + /** + *

Remove duplicate values.

+ * + *

Removes all but the first element from every consecutive group of equal elements in the

+ * + *

Notice that an element is only removed from the {@link List} container if it compares equal to the + * element immediately preceding it. Thus, this function is especially useful for sorted lists.

+ */ + unique(): void; + /** + *

Remove duplicate values.

+ * + *

Removes all but the first element from every consecutive group of equal elements in the

+ * + *

The argument binary_pred is a specific comparison function that determine the uniqueness + * of an element. In fact, any behavior can be implemented (and not only an equality comparison), but notice + * that the function will call binary_pred(it.value, it.prev().value) for all pairs of elements + * (where it is an iterator to an element, starting from the second) and remove it + * from the {@link List} if the predicate returns true. + * + *

Notice that an element is only removed from the {@link List} container if it compares equal to the + * element immediately preceding it. Thus, this function is especially useful for sorted lists.

+ * + * @param binary_pred Binary predicate that, taking two values of the same type than those contained in the + * {@link List}, returns true to remove the element passed as first argument + * from the container, and false otherwise. This shall be a function pointer + * or a function object. + */ + unique(binary_pred: (left: T, right: T) => boolean): void; + /** + *

Remove elements with specific value.

+ * + *

Removes from the container all the elements that compare equal to val. This calls the + * destructor of these objects and reduces the container {@link size} by the number of elements removed.

+ * + *

Unlike member function {@link List.erase}, which erases elements by their position (using an + * iterator), this function ({@link List.remove}) removes elements by their value.

+ * + *

A similar function, {@link List.remove_if}, exists, which allows for a condition other than an + * equality comparison to determine whether an element is removed.

+ * + * @param val Value of the elements to be removed. + */ + remove(val: T): void; + /** + *

Remove elements fulfilling condition.

+ * + *

Removes from the container all the elements for which pred returns true. This + * calls the destructor of these objects and reduces the container {@link size} by the number of elements + * removed.

+ * + *

The function calls pred(it.value) for each element (where it is an iterator + * to that element). Any of the elements in the list for which this returns true, are removed + * from the

+ * + * @param pred Unary predicate that, taking a value of the same type as those contained in the forward_list + * object, returns true for those values to be removed from the container, and + * false for those remaining. This can either be a function pointer or a function + * object. + */ + remove_if(pred: (val: T) => boolean): void; + /** + *

Merge sorted {@link List Lists}.

+ * + *

Merges obj into the {@link List} by transferring all of its elements at their respective + * ordered positions into the container (both containers shall already be ordered). + *

+ * + *

This effectively removes all the elements in obj (which becomes {@link empty}), and inserts + * them into their ordered position within container (which expands in {@link size} by the number of elements + * transferred). The operation is performed without constructing nor destroying any element: they are + * transferred, no matter whether obj is an lvalue or an rvalue, or whether the value_type supports + * move-construction or not.

+ * + *

This function requires that the {@link List} containers have their elements already ordered by value + * ({@link less}) before the call. For an alternative on unordered {@link List Lists}, see + * {@link List.splice}.

+ * + *

Assuming such ordering, each element of obj is inserted at the position that corresponds to its + * value according to the strict weak ordering defined by {@link less}. The resulting order of equivalent + * elements is stable (i.e., equivalent elements preserve the relative order they had before the call, and + * existing elements precede those equivalent inserted from obj).

+ * + * The function does nothing if this == obj. + * + * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). + * Note that this function modifies obj no matter whether an lvalue or rvalue reference is + * passed. + */ + merge(obj: List): void; + /** + *

Merge sorted {@link List Lists}.

+ * + *

Merges obj into the {@link List} by transferring all of its elements at their respective + * ordered positions into the container (both containers shall already be ordered). + *

+ * + *

This effectively removes all the elements in obj (which becomes {@link empty}), and inserts + * them into their ordered position within container (which expands in {@link size} by the number of elements + * transferred). The operation is performed without constructing nor destroying any element: they are + * transferred, no matter whether obj is an lvalue or an rvalue, or whether the value_type supports + * move-construction or not.

+ * + *

The argument compare is a specific predicate to perform the comparison operation between + * elements. This comparison shall produce a strict weak ordering of the elements (i.e., a consistent + * transitive comparison, without considering its reflexiveness). + * + *

This function requires that the {@link List} containers have their elements already ordered by + * compare before the call. For an alternative on unordered {@link List Lists}, see + * {@link List.splice}.

+ * + *

Assuming such ordering, each element of obj is inserted at the position that corresponds to its + * value according to the strict weak ordering defined by compare. The resulting order of equivalent + * elements is stable (i.e., equivalent elements preserve the relative order they had before the call, and + * existing elements precede those equivalent inserted from obj).

+ * + * The function does nothing if this == obj. + * + * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). + * Note that this function modifies obj no matter whether an lvalue or rvalue reference is + * passed. + * @param compare Binary predicate that, taking two values of the same type than those contained in the + * {@link list}, returns true if the first argument is considered to go before + * the second in the strict weak ordering it defines, and false otherwise. + * This shall be a function pointer or a function object. + */ + merge(obj: List, compare: (left: T, right: T) => boolean): void; + /** + *

Transfer elements from {@link List} to {@link List}.

+ * + *

Transfers elements from obj into the container, inserting them at position.

+ * + *

This effectively inserts all elements into the container and removes them from obj, altering + * the sizes of both containers. The operation does not involve the construction or destruction of any + * element. They are transferred, no matter whether obj is an lvalue or an rvalue, or whether the + * value_type supports move-construction or not.

+ * + *

This first version (1) transfers all the elements of obj into the

+ * + * @param position Position within the container where the elements of obj are inserted. + * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). + */ + splice(position: ListIterator, obj: List): void; + /** + *

Transfer an element from {@link List} to {@link List}.

+ * + *

Transfers an element from obj, which is pointed by an {@link ListIterator iterator} it, + * into the container, inserting the element at specified position.

+ * + *

This effectively inserts an element into the container and removes it from obj, altering the + * sizes of both containers. The operation does not involve the construction or destruction of any element. + * They are transferred, no matter whether obj is an lvalue or an rvalue, or whether the value_type + * supports move-construction or not.

+ * + *

This second version (2) transfers only the element pointed by it from obj into the + *

+ * + * @param position Position within the container where the element of obj is inserted. + * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). + * This parameter may be this if position points to an element not actually + * being spliced. + * @param it {@link ListIterator Iterator} to an element in obj. Only this single element is + * transferred. + */ + splice(position: ListIterator, obj: List, it: ListIterator): void; + /** + *

Transfer elements from {@link List} to {@link List}.

+ * + *

Transfers elements from obj into the container, inserting them at position.

+ * + *

This effectively inserts those elements into the container and removes them from obj, altering + * the sizes of both containers. The operation does not involve the construction or destruction of any + * element. They are transferred, no matter whether obj is an lvalue or an rvalue, or whether the + * value_type supports move-construction or not.

+ * + *

This third version (3) transfers the range [begin, end) from obj into the + *

+ * + * @param position Position within the container where the elements of obj are inserted. + * @param obj A {@link List} object of the same type (i.e., with the same template parameters, T). + * This parameter may be this if position points to an element not actually + * being spliced. + * @param begin {@link ListIterator An Iterator} specifying initial position of a range of elements in + * obj. Transfers the elements in the range [begin, end) to + * position. + * @param end {@link ListIterator An Iterator} specifying final position of a range of elements in + * obj. Transfers the elements in the range [begin, end) to + * position. Notice that the range includes all the elements between begin and + * end, including the element pointed by begin but not the one pointed by end. + */ + splice(position: ListIterator, obj: List, begin: ListIterator, end: ListIterator): void; + /** + *

Sort elements in

+ * + *

Sorts the elements in the {@link List}, altering their position within the

+ * + *

The sorting is performed by applying an algorithm that uses {@link less}. This comparison shall + * produce a strict weak ordering of the elements (i.e., a consistent transitive comparison, without + * considering its reflexiveness).

+ * + *

The resulting order of equivalent elements is stable: i.e., equivalent elements preserve the relative + * order they had before the call.

+ * + *

The entire operation does not involve the construction, destruction or copy of any element object. + * Elements are moved within the

+ */ + sort(): void; + /** + *

Sort elements in

+ * + *

Sorts the elements in the {@link List}, altering their position within the

+ * + *

The sorting is performed by applying an algorithm that uses compare. This comparison shall + * produce a strict weak ordering of the elements (i.e., a consistent transitive comparison, without + * considering its reflexiveness).

+ * + *

The resulting order of equivalent elements is stable: i.e., equivalent elements preserve the relative + * order they had before the call.

+ * + *

The entire operation does not involve the construction, destruction or copy of any element object. + * Elements are moved within the

+ * + * @param compare Binary predicate that, taking two values of the same type of those contained in the + * {@link List}, returns true if the first argument goes before the second + * argument in the strict weak ordering it defines, and false otherwise. This + * shall be a function pointer or a function object. + */ + sort(compare: (left: T, right: T) => boolean): void; + /** + * @hidden + */ + private qsort(first, last, compare); + /** + * @hidden + */ + private partition(first, last, compare); + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link List container} object with same type of elements. Sizes and container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were in obj + * before the call, and the elements of obj are those which were in this. All iterators, references and + * pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link List container} of the same type of elements (i.e., instantiated + * with the same template parameter, T) whose content is swapped with that of this + * {@link container List}. + */ + swap(obj: List): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + } +} +declare namespace std { + /** + *

An iterator, node of a List.

+ * + *

+ * + *

+ * + * @author Jeongho Nam + */ + class ListIterator extends Iterator { + /** + * @hidden + */ + private prev_; + /** + * @hidden + */ + private next_; + /** + * @hidden + */ + private value_; + /** + *

Construct from the source {@link List container}.

+ * + *

Note

+ *

Do not create the iterator directly, by yourself.

+ *

Use {@link List.begin begin()}, {@link List.end end()} in {@link List container} instead.

+ * + * @param source The source {@link List container} to reference. + * @param prev A refenrece of previous node ({@link ListIterator iterator}). + * @param next A refenrece of next node ({@link ListIterator iterator}). + * @param value Value to be stored in the node (iterator). + */ + constructor(source: List, prev: ListIterator, next: ListIterator, value: T); + private list(); + /** + * @inheritdoc + */ + prev(): ListIterator; + /** + * @inheritdoc + */ + next(): ListIterator; + /** + * @inheritdoc + */ + advance(step: number): ListIterator; + /** + * @inheritdoc + */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ + value: T; + /** + * @inheritdoc + */ + equal_to(obj: ListIterator): boolean; + /** + * @inheritdoc + */ + swap(obj: ListIterator): void; + } +} +declare namespace std { + /** + *

A reverse-iterator of List.

+ * + *

+ * + *

+ * + * @param Type of the elements. + * + * @author Jeongho Nam + */ + class ListReverseIterator extends ReverseIterator, ListReverseIterator> { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ + constructor(base: ListIterator); + /** + * @hidden + */ + protected create_neighbor(base: ListIterator): ListReverseIterator; + /** + * @inheritdoc + */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ + value: T; + } +} +declare namespace std.Vector { + type iterator = std.VectorIterator; + type reverse_iterator = std.VectorReverseIterator; +} +declare namespace std { + /** + *

Vector, the dynamic array.

+ * + *

{@link Vector}s are sequence containers representing arrays that can change in size.

+ * + *

Just like arrays, {@link Vector}s use contiguous storage locations for their elements, which means that + * their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently + * as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled + * automatically by the

+ * + *

Internally, {@link Vector}s use a dynamically allocated array to store their elements. This array may need + * to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new + * array and moving all elements to it. This is a relatively expensive task in terms of processing time, and + * thus, {@link Vector}s do not reallocate each time an element is added to the

+ * + *

Instead, {@link Vector} containers may allocate some extra storage to accommodate for possible growth, and + * thus the container may have an actual {@link capacity} greater than the storage strictly needed to contain its + * elements (i.e., its {@link size}). Libraries can implement different strategies for growth to balance between + * memory usage and reallocations, but in any case, reallocations should only happen at logarithmically growing + * intervals of {@link size} so that the insertion of individual elements at the end of the {@link Vector} can be + * provided with amortized constant time complexity (see {@link push_back push_back()}).

+ * + *

Therefore, compared to arrays, {@link Vector}s consume more memory in exchange for the ability to manage + * storage and grow dynamically in an efficient way.

+ * + *

Compared to the other dynamic sequence containers ({@link Deque}s, {@link List}s), {@link Vector Vectors} + * are very efficient accessing its elements (just like arrays) and relatively efficient adding or removing + * elements from its end. For operations that involve inserting or removing elements at positions other than the + * end, they perform worse than the others, and have less consistent iterators and references than {@link List}s. + *

+ * + *

+ * + *

+ * + *

Container properties

+ *
+ *
Sequence
+ *
+ * Elements in sequence containers are ordered in a strict linear sequence. Individual elements are + * accessed by their position in this sequence. + *
+ * + *
Dynamic array
+ *
+ * Allows direct access to any element in the sequence, even through pointer arithmetics, and provides + * relatively fast addition/removal of elements at the end of the sequence. + *
+ *
+ * + * @param Type of the elements. + * + * @reference http://www.cplusplus.com/reference/vector/vector + * @author Jeongho Nam + */ + class Vector extends Array implements base.IContainer, base.IArrayContainer { + /** + *

Default Constructor.

+ * + *

Constructs an empty container, with no elements.

+ */ + constructor(); + /** + * @inheritdoc + */ + constructor(array: Array); + /** + *

Initializer list Constructor.

+ * + *

Constructs a container with a copy of each of the elements in array, in the same order.

+ * + * @param array An array containing elements to be copied and contained. + */ + constructor(n: number); + /** + *

Fill Constructor.

+ * + *

Constructs a container with n elements. Each element is a copy of val (if provided).

+ * + * @param n Initial container size (i.e., the number of elements in the container at construction). + * @param val Value to fill the container with. Each of the n elements in the container is + * initialized to a copy of this value. + */ + constructor(n: number, val: T); + /** + *

Copy Constructor.

+ * + *

Constructs a container with a copy of each of the elements in container, in the same order.

+ * + * @param container Another container object of the same type (with the same class template + * arguments T), whose contents are either copied or acquired. + */ + constructor(container: Vector); + /** + *

Range Constructor.

+ * + *

Constructs a container with as many elements as the range (begin, end), with each + * element emplace-constructed from its corresponding element in that range, in the same order.

+ * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * @inheritdoc + */ + assign>(begin: InputIterator, end: InputIterator): void; + /** + * @inheritdoc + */ + assign(n: number, val: T): void; + /** + * @inheritdoc + */ + reserve(size: number): void; + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + begin(): VectorIterator; + /** + * @inheritdoc + */ + end(): VectorIterator; + /** + * @inheritdoc + */ + rbegin(): VectorReverseIterator; + /** + * @inheritdoc + */ + rend(): VectorReverseIterator; + /** + * @inheritdoc + */ + size(): number; + /** + * @inheritdoc + */ + capacity(): number; + /** + * @inheritdoc + */ + empty(): boolean; + /** + * @inheritdoc + */ + at(index: number): T; + /** + * @inheritdoc + */ + set(index: number, val: T): T; + /** + * @inheritdoc + */ + front(): T; + /** + * @inheritdoc + */ + back(): T; + /** + * @inheritdoc + */ + push_back(val: T): void; + /** + *

Insert an element.

+ * + *

The {@link Vector} is extended by inserting new element before the element at the specified + * position, effectively increasing the container size by one.

+ * + *

This causes an automatic reallocation of the allocated storage space if -and only if- the new + * {@link size} surpasses the current {@link capacity}.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, inserting element in + * positions other than the {@link end end()} causes the container to relocate all the elements that were + * after position to its new position. This is generally an inefficient operation compared to the one + * performed for the same operation by other kinds of sequence containers (such as {@link List}).

+ * + * @param position Position in the {@link Vector} where the new element is inserted. + * {@link iterator} is a member type, defined as a + * {@link VectorIterator random access iterator} type that points to elements. + * @param val Value to be copied to the inserted element. + * + * @return An iterator that points to the newly inserted element. + */ + insert(position: VectorIterator, val: T): VectorIterator; + /** + *

Insert elements by repeated filling.

+ * + *

The {@link Vector} is extended by inserting new elements before the element at the specified + * position, effectively increasing the container size by the number of elements inserted.

+ * + *

This causes an automatic reallocation of the allocated storage space if -and only if- the new + * {@link size} surpasses the current {@link capacity}.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in + * positions other than the {@link end end()} causes the container to relocate all the elements that were + * after position to their new positions. This is generally an inefficient operation compared to the + * one performed for the same operation by other kinds of sequence containers (such as {@link List}). + * + * @param position Position in the {@link Vector} where the new elements are inserted. + * {@link iterator} is a member type, defined as a + * {@link VectorIterator random access iterator} type that points to elements. + * @param n Number of elements to insert. Each element is initialized to a copy of val. + * @param val Value to be copied (or moved) to the inserted elements. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert(position: VectorIterator, n: number, val: T): VectorIterator; + /** + *

Insert elements by range iterators.

+ * + *

The {@link Vector} is extended by inserting new elements before the element at the specified + * position, effectively increasing the container size by the number of elements inserted by range + * iterators.

+ * + *

This causes an automatic reallocation of the allocated storage space if -and only if- the new + * {@link size} surpasses the current {@link capacity}.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in + * positions other than the {@link end end()} causes the container to relocate all the elements that were + * after position to their new positions. This is generally an inefficient operation compared to the + * one performed for the same operation by other kinds of sequence containers (such as {@link List}). + * + * @param position Position in the {@link Vector} where the new elements are inserted. + * {@link iterator} is a member type, defined as a + * {@link VectorIterator random access iterator} type that points to elements. + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert>(position: VectorIterator, begin: InputIterator, end: InputIterator): VectorIterator; + /** + *

Insert an element.

+ * + *

The {@link Vector} is extended by inserting new element before the element at the specified + * position, effectively increasing the container size by one.

+ * + *

This causes an automatic reallocation of the allocated storage space if -and only if- the new + * {@link size} surpasses the current {@link capacity}.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, inserting element in + * positions other than the {@link end end()} causes the container to relocate all the elements that were + * after position to its new position. This is generally an inefficient operation compared to the one + * performed for the same operation by other kinds of sequence containers (such as {@link List}).

+ * + * @param position Position in the {@link Vector} where the new element is inserted. + * {@link iterator} is a member type, defined as a + * {@link VectorIterator random access iterator} type that points to elements. + * @param val Value to be copied to the inserted element. + * + * @return An iterator that points to the newly inserted element. + */ + insert(position: VectorReverseIterator, val: T): VectorReverseIterator; + /** + *

Insert elements by repeated filling.

+ * + *

The {@link Vector} is extended by inserting new elements before the element at the specified + * position, effectively increasing the container size by the number of elements inserted.

+ * + *

This causes an automatic reallocation of the allocated storage space if -and only if- the new + * {@link size} surpasses the current {@link capacity}.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in + * positions other than the {@link end end()} causes the container to relocate all the elements that were + * after position to their new positions. This is generally an inefficient operation compared to the + * one performed for the same operation by other kinds of sequence containers (such as {@link List}). + * + * @param position Position in the {@link Vector} where the new elements are inserted. + * {@link iterator} is a member type, defined as a + * {@link VectorIterator random access iterator} type that points to elements. + * @param n Number of elements to insert. Each element is initialized to a copy of val. + * @param val Value to be copied (or moved) to the inserted elements. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert(position: VectorReverseIterator, n: number, val: T): VectorReverseIterator; + /** + *

Insert elements by range iterators.

+ * + *

The {@link Vector} is extended by inserting new elements before the element at the specified + * position, effectively increasing the container size by the number of elements inserted by range + * iterators.

+ * + *

This causes an automatic reallocation of the allocated storage space if -and only if- the new + * {@link size} surpasses the current {@link capacity}.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, inserting elements in + * positions other than the {@link end end()} causes the container to relocate all the elements that were + * after position to their new positions. This is generally an inefficient operation compared to the + * one performed for the same operation by other kinds of sequence containers (such as {@link List}). + * + * @param position Position in the {@link Vector} where the new elements are inserted. + * {@link iterator} is a member type, defined as a + * {@link VectorIterator random access iterator} type that points to elements. + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * + * @return An iterator that points to the first of the newly inserted elements. + */ + insert>(position: VectorReverseIterator, begin: InputIterator, end: InputIterator): VectorReverseIterator; + /** + * @hidden + */ + private insert_by_val(position, val); + /** + * @hidden + */ + protected _Insert_by_repeating_val(position: VectorIterator, n: number, val: T): VectorIterator; + /** + * @hidden + */ + protected _Insert_by_range>(position: VectorIterator, first: InputIterator, last: InputIterator): VectorIterator; + /** + * @inheritdoc + */ + pop_back(): void; + /** + *

Erase element.

+ * + *

Removes from the {@link Vector} either a single element; position.

+ * + *

This effectively reduces the container size by the number of element removed.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, erasing an element in + * position other than the {@link end end()} causes the container to relocate all the elements after the + * segment erased to their new positions. This is generally an inefficient operation compared to the one + * performed for the same operation by other kinds of sequence containers (such as {@link List}).

+ * + * @param position Iterator pointing to a single element to be removed from the {@link Vector}. + * + * @return An iterator pointing to the new location of the element that followed the last element erased by + * the function call. This is the {@link end end()} if the operation erased the last element in the + * sequence. + */ + erase(position: VectorIterator): VectorIterator; + /** + *

Erase element.

+ * + *

Removes from the Vector either a single element; position.

+ * + *

This effectively reduces the container size by the number of elements removed.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, erasing elements in + * position other than the {@link end end()} causes the container to relocate all the elements after the + * segment erased to their new positions. This is generally an inefficient operation compared to the one + * performed for the same operation by other kinds of sequence containers (such as {@link List}).

+ * + * @param begin An iterator specifying a range of beginning to erase. + * @param end An iterator specifying a range of end to erase. + * + * @return An iterator pointing to the new location of the element that followed the last element erased by + * the function call. This is the {@link rend rend()} if the operation erased the last element in the + * sequence. + */ + erase(first: VectorIterator, last: VectorIterator): VectorIterator; + /** + *

Erase element.

+ * + *

Removes from the {@link Vector} either a single element; position.

+ * + *

This effectively reduces the container size by the number of element removed.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, erasing an element in + * position other than the {@link end end()} causes the container to relocate all the elements after the + * segment erased to their new positions. This is generally an inefficient operation compared to the one + * performed for the same operation by other kinds of sequence containers (such as {@link List}).

+ * + * @param position Iterator pointing to a single element to be removed from the {@link Vector}. + * + * @return An iterator pointing to the new location of the element that followed the last element erased by + * the function call. This is the {@link rend rend()} if the operation erased the last element in the + * sequence. + */ + erase(position: VectorReverseIterator): VectorReverseIterator; + /** + *

Erase element.

+ * + *

Removes from the Vector either a single element; position.

+ * + *

This effectively reduces the container size by the number of elements removed.

+ * + *

Because {@link Vector}s use an Array as their underlying storage, erasing elements in + * position other than the {@link end end()} causes the container to relocate all the elements after the + * segment erased to their new positions. This is generally an inefficient operation compared to the one + * performed for the same operation by other kinds of sequence containers (such as {@link List}).

+ * + * @param begin An iterator specifying a range of beginning to erase. + * @param end An iterator specifying a range of end to erase. + * + * @return An iterator pointing to the new location of the element that followed the last element erased by + * the function call. This is the {@link end end()} if the operation erased the last element in the + * sequence. + */ + erase(first: VectorReverseIterator, last: VectorReverseIterator): VectorReverseIterator; + /** + * @hidden + */ + protected _Erase_by_range(first: VectorIterator, last: VectorIterator): VectorIterator; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link Vector container} object with same type of elements. Sizes and container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were in obj + * before the call, and the elements of obj are those which were in this. All iterators, references and + * pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link Vector container} of the same type of elements (i.e., instantiated + * with the same template parameter, T) whose content is swapped with that of this + * {@link container Vector}. + */ + obj(obj: Vector): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + } +} +declare namespace std { + /** + *

An iterator of Vector.

+ * + *

+ * + *

+ * + * @param Type of the elements. + * + * @author Jeongho Nam + */ + class VectorIterator extends Iterator implements base.IArrayIterator { + /** + * Sequence number of iterator in the source {@link Vector}. + */ + private index_; + /** + *

Construct from the source {@link Vector container}.

+ * + *

Note

+ *

Do not create the iterator directly, by yourself.

+ *

Use {@link Vector.begin begin()}, {@link Vector.end end()} in {@link Vector container} instead.

+ * + * @param source The source {@link Vector container} to reference. + * @param index Sequence number of the element in the source {@link Vector}. + */ + constructor(source: Vector, index: number); + /** + * @hidden + */ + private readonly vector; + /** + * @inheritdoc + */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ + value: T; + /** + * Get index. + */ + readonly index: number; + /** + * @inheritdoc + */ + prev(): VectorIterator; + /** + * @inheritdoc + */ + next(): VectorIterator; + /** + * @inheritdoc + */ + advance(n: number): VectorIterator; + /** + *

Whether an iterator is equal with the iterator.

+ * + *

Compare two iterators and returns whether they are equal or not.

+ * + *

Note

+ *

Iterator's equal_to() only compare souce container and index number.

+ * + *

Although elements in a pair, key and value are equal_to, if the source map or + * index number is different, then the {@link equal_to equal_to()} will return false. If you want to + * compare the elements of a pair, compare them directly by yourself.

+ * + * @param obj An iterator to compare + * @return Indicates whether equal or not. + */ + equal_to(obj: VectorIterator): boolean; + /** + * @inheritdoc + */ + swap(obj: VectorIterator): void; + } +} +declare namespace std { + /** + *

A reverse-iterator of Vector.

+ * + *

+ * + *

+ * + * @param Type of the elements. + * + * @author Jeongho Nam + */ + class VectorReverseIterator extends ReverseIterator, VectorReverseIterator> implements base.IArrayIterator { + /** + * Construct from base iterator. + * + * @param base A reference of the base iterator, which iterates in the opposite direction. + */ + constructor(base: VectorIterator); + /** + * @hidden + */ + protected create_neighbor(base: VectorIterator): VectorReverseIterator; + /** + * @inheritdoc + */ + /** + * Set value of the iterator is pointing to. + * + * @param val Value to set. + */ + value: T; + /** + * Get index. + */ + readonly index: number; + } +} +declare namespace std { + /** + *

FIFO queue.

+ * + *

{@link Queue}s are a type of container adaptor, specifically designed to operate in a FIFO context + * (first-in first-out), where elements are inserted into one end of the container and extracted from the other. + *

+ * + *

{@link Queue}s are implemented as containers adaptors, which are classes that use an encapsulated object of + * a specific container class as its underlying container, providing a specific set of member functions to access + * its elements. Elements are pushed into the {@link IDeque.back back()} of the specific container and popped from + * its {@link IDeque.front front()}.

+ * + *

{@link container_ The underlying container} may be one of the standard container class template or some + * other specifically designed container class. This underlying container shall support at least the following + * operations:

+ * + *
    + *
  • empty
  • + *
  • size
  • + *
  • front
  • + *
  • back
  • + *
  • push_back
  • + *
  • pop_front
  • + *
+ * + *

The standard container classes {@link Deque} and {@link List} fulfill these requirements. + * By default, if no container class is specified for a particular {@link Queue} class instantiation, the standard + * container {@link List} is used.

+ * + *

+ * + *

+ * + * @param Type of elements. + * + * @reference http://www.cplusplus.com/reference/queue/queue + * @author Jeongho Nam + */ + class Queue { + /** + * The underlying object for implementing the FIFO + */ + private container_; + /** + * Default Constructor. + */ + constructor(); + /** + * Copy Constructor. + */ + constructor(container: Queue); + /** + *

Return size.

+ *

Returns the number of elements in the {@link Queue}.

+ * + *

This member function effectively calls member {@link IDeque.size size()} of the + * {@link container_ underlying container} object.

+ * + * @return The number of elements in the {@link container_ underlying container}. + */ + size(): number; + /** + *

Test whether container is empty.

+ *

returns whether the {@link Queue} is empty: i.e. whether its size is zero.

+ * + *

This member function efeectively calls member {@link IDeque.empty empty()} of the + * {@link container_ underlying container} object.

+ * + * @return true if the {@link container_ underlying container}'s size is 0, + * false otherwise.

+ */ + empty(): boolean; + /** + *

Access next element.

+ *

Returns a value of the next element in the {@link Queue}.

+ * + *

The next element is the "oldest" element in the {@link Queue} and the same element that is popped out + * from the queue when {@link pop Queue.pop()} is called.

+ * + *

This member function effectively calls member {@link IDeque.front front()} of the + * {@link container_ underlying container} object.

+ * + * @return A value of the next element in the {@link Queue}. + */ + front(): T; + /** + *

Access last element.

+ * + *

Returns a vaue of the last element in the queue. This is the "newest" element in the queue (i.e. the + * last element pushed into the queue).

+ * + *

This member function effectively calls the member function {@link IDeque.back back()} of the + * {@link container_ underlying container} object.

+ * + * @return A value of the last element in the {@link Queue}. + */ + back(): T; + /** + *

Insert element.

+ * + *

Inserts a new element at the end of the {@link Queue}, after its current last element. + * The content of this new element is initialized to val.

+ * + *

This member function effectively calls the member function {@link IDeque.push_back push_back()} of the + * {@link container_ underlying container} object.

+ * + * @param val Value to which the inserted element is initialized. + */ + push(val: T): void; + /** + *

Remove next element.

+ * + *

Removes the next element in the {@link Queue}, effectively reducing its size by one.

+ * + *

The element removed is the "oldest" element in the {@link Queue} whose value can be retrieved by calling + * member {@link front Queue.front()}

. + * + *

This member function effectively calls the member function {@link IDeque.pop_front pop_front()} of the + * {@link container_ underlying container} object.

+ */ + pop(): void; + /** + *

Swap contents.

+ * + *

Exchanges the contents of the container adaptor (this) by those of obj.

+ * + *

This member function calls the non-member function {@link IContainer.swap swap} (unqualified) to swap + * the {@link container_ underlying containers}.

+ * + * @param obj Another {@link Queue} container adaptor of the same type (i.e., instantiated with the same + * template parameter, T). Sizes may differ.

+ */ + swap(obj: Queue): void; + } +} +declare namespace std { + /** + *

LIFO stack.

+ * + *

{@link Stack}s are a type of container adaptor, specifically designed to operate in a LIFO context + * (last-in first-out), where elements are inserted and extracted only from one end of the

+ * + *

{@link Stack}s are implemented as containers adaptors, which are classes that use an encapsulated object of + * a specific container class as its underlying container, providing a specific set of member functions to + * access its elements. Elements are pushed/popped from the {@link ILinearContainer.back back()} of the + * {@link ILinearContainer specific container}, which is known as the top of the {@link Stack}.

+ * + *

{@link container_ The underlying container} may be any of the standard container class templates or some + * other specifically designed container class. The container shall support the following operations:

+ * + *
    + *
  • empty
  • + *
  • size
  • + *
  • front
  • + *
  • back
  • + *
  • push_back
  • + *
  • pop_back
  • + *
+ * + *

The standard container classes {@link Vector}, {@link Deque} and {@link List} fulfill these requirements. + * By default, if no container class is specified for a particular {@link Stack} class instantiation, the standard + * container {@link List} is used.

+ * + *

+ * + *

+ * + * @param Type of elements. + * + * @reference http://www.cplusplus.com/reference/stack/stack + * @author Jeongho Nam + */ + class Stack { + /** + * The underlying object for implementing the LIFO + */ + private container_; + /** + * Default Constructor. + */ + constructor(); + /** + * Copy Constructor. + */ + constructor(stack: Stack); + /** + *

Return size.

+ * + *

Returns the number of elements in the {@link Stack}.

+ * + *

This member function effectively calls member {@link ILinearContainer.size size()} of the + * {@link container_ underlying container} object.

+ * + * @return The number of elements in the {@link container_ underlying container}. + */ + size(): number; + /** + *

Test whether container is empty.

+ * + *

returns whether the {@link Stack} is empty: i.e. whether its size is zero.

+ * + *

This member function effectively calls member {@link ILinearContainer.empty empty()} of the + * {@link container_ underlying container} object.

+ * + * @return true if the underlying container's size is 0, + * false otherwise.

+ */ + empty(): boolean; + /** + *

Access next element.

+ * + *

Returns a value of the top element in the {@link Stack}

. + * + *

Since {@link Stack}s are last-in first-out containers, the top element is the last element inserted into + * the {@link Stack}.

+ * + *

This member function effectively calls member {@link ILinearContainer.back back()} of the + * {@link container_ underlying container} object.

+ * + * @return A value of the top element in the {@link Stack}. + */ + top(): T; + /** + *

Insert element.

+ * + *

Inserts a new element at the top of the {@link Stack}, above its current top element.

+ * + *

This member function effectively calls the member function + * {@link ILinearContainer.push_back push_back()} of the {@link container_ underlying container} object.

+ * + * @param val Value to which the inserted element is initialized. + */ + push(val: T): void; + /** + *

Remove top element.

+ * + *

Removes the element on top of the {@link Stack}, effectively reducing its size by one.

+ * + *

The element removed is the latest element inserted into the {@link Stack}, whose value can be retrieved + * by calling member {@link top Stack.top()}

. + * + *

This member function effectively calls the member function {@link ILinearContainer.pop_back pop_back()} + * of the {@link container_ underlying container} object.

+ */ + pop(): void; + /** + *

Swap contents.

+ * + *

Exchanges the contents of the container adaptor (this) by those of obj.

+ * + *

This member function calls the non-member function {@link IContainer.swap swap} (unqualified) to swap + * the {@link container_ underlying containers}.

+ * + * @param obj Another {@link Stack} container adaptor of the same type (i.e., instantiated with the same + * template parameter, T). Sizes may differ.

+ */ + swap(obj: Stack): void; + } +} +declare namespace std.TreeSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

Tree-structured set, std::set of STL.

+ * + *

{@link TreeSet}s are containers that store unique elements following a specific order.

+ * + *

In a {@link TreeSet}, the value of an element also identifies it (the value is itself the + * key, of type T), and each value must be unique. The value of the elements in a + * {@link TreeSet} cannot be modified once in the container (the elements are always const), but they + * can be inserted or removed from the

+ * + *

Internally, the elements in a {@link TreeSet} are always sorted following a specific strict weak + * ordering criterion indicated by its internal comparison method (of {@link less}).

+ * + *

{@link TreeSet} containers are generally slower than {@link HashSet} containers to access + * individual elements by their key, but they allow the direct iteration on subsets based on their + * order.

+ * + *

{@link TreeSet}s are typically implemented as binary search trees.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
+ * + *
Ordered
+ *
+ * The elements in the container follow a strict order at all times. All inserted elements are + * given a position in this order. + *
+ * + *
Set
+ *
The value of an element is also the key used to identify it.
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the elements. + * Each element in an {@link TreeSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/set/set + * @author Jeongho Nam + */ + class TreeSet extends base.UniqueSet implements base.ITreeSet { + /** + * @hidden + */ + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (x: T, y: T) => boolean); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + */ + constructor(array: Array); + /** + * Contruct from elements with compare. + * + * @param array Elements to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array, compare: (x: T, y: T) => boolean); + /** + * Copy Constructor. + */ + constructor(container: TreeMultiSet); + /** + * Copy Constructor with compare. + * + * @param container A container to be copied. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: TreeMultiSet, compare: (x: T, y: T) => boolean); + /** + * Range Constructor. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * Construct from range and compare. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * @param compare A binary predicate determines order of elements. + */ + constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(val: T): SetIterator; + /** + * @inheritdoc + */ + key_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + lower_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + upper_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + equal_range(val: T): Pair, SetIterator>; + /** + * @hidden + */ + protected _Insert_by_val(val: T): any; + protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: SetIterator, last: SetIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link TreeSet set} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link TreeSet set container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link TreeSet container}. + */ + swap(obj: TreeSet): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + } +} +declare namespace std.TreeMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} +declare namespace std { + /** + *

Tree-structured map, std::map of STL.

+ * + *

{@link TreeMap TreeMaps} are associative containers that store elements formed by a combination of a + * key value (Key) and a mapped value (T), following order.

+ * + *

In a {@link TreeMap}, the key values are generally used to sort and uniquely identify the elements, + * while the mapped values store the content associated to this key. The types of key and + * mapped value may differ, and are grouped together in member type value_type, which is a {@link Pair} + * type combining both:

+ * + *

typedef Pair value_type;

+ * + *

Internally, the elements in a {@link TreeMap} are always sorted by its key following a + * strict weak ordering criterion indicated by its internal comparison method {@link less}. + * + *

{@link TreeMap} containers are generally slower than {@link HashMap HashMap} containers to access individual + * elements by their key, but they allow the direct iteration on subsets based on their order.

+ * + *

{@link TreeMap}s are typically implemented as binary search trees.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
+ * + *
Ordered
+ *
The elements in the container follow a strict order at all times. All inserted elements are + * given a position in this order.
+ * + *
Map
+ *
Each element associates a key to a mapped value: + * Keys are meant to identify the elements whose main content is the mapped value.
+ * + *
Unique keys
+ *
No two elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the keys. Each element in a map is uniquely identified by its key value. + * @param Type of the mapped value. Each element in a map stores some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/map/map + * @author Jeongho Nam + */ + class TreeMap extends base.UniqueMap implements base.ITreeMap { + /** + * @hidden + */ + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (x: Key, y: Key) => boolean); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + */ + constructor(array: Array>); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array>, compare: (x: Key, y: Key) => boolean); + /** + * Contruct from tuples. + * + * @param array Tuples to be contained. + */ + constructor(array: Array<[Key, T]>); + /** + * Contruct from tuples. + * + * @param array Tuples to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array<[Key, T]>, compare: (x: Key, y: Key) => boolean); + /** + * Copy Constructor. + * + * @param container Another map to copy. + */ + constructor(container: TreeMap); + /** + * Copy Constructor. + * + * @param container Another map to copy. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: TreeMap, compare: (x: Key, y: Key) => boolean); + /** + * Range Constructor. + * + * @param begin nput interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator>, end: Iterator>); + /** + * Range Constructor. + * + * @param begin nput interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * @param compare A binary predicate determines order of elements. + */ + constructor(begin: Iterator>, end: Iterator>, compare: (x: Key, y: Key) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: Key): MapIterator; + /** + * @inheritdoc + */ + key_comp(): (x: Key, y: Key) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: Pair, y: Pair) => boolean; + /** + * @inheritdoc + */ + lower_bound(key: Key): MapIterator; + /** + * @inheritdoc + */ + upper_bound(key: Key): MapIterator; + /** + * @inheritdoc + */ + equal_range(key: Key): Pair, MapIterator>; + /** + * @hidden + */ + protected _Insert_by_pair(pair: Pair): any; + /** + * @hidden + */ + protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; + /** + * @hidden + */ + protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: MapIterator, last: MapIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: MapIterator, last: MapIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link TreeMap map} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link TreeMap map container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link TreeMap container}. + */ + swap(obj: TreeMap): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer>): void; + } +} +declare namespace std.TreeMultiSet { + type iterator = std.SetIterator; + type reverse_iterator = std.SetReverseIterator; +} +declare namespace std { + /** + *

Tree-structured multiple-key set.

+ * + *

{@link TreeMultiSet TreeMultiSets} are containers that store elements following a specific order, and + * where multiple elements can have equivalent values.

+ * + *

In a {@link TreeMultiSet}, the value of an element also identifies it (the value is itself + * the key, of type T). The value of the elements in a {@link TreeMultiSet} cannot + * be modified once in the container (the elements are always const), but they can be inserted or removed + * from the

+ * + *

Internally, the elements in a {@link TreeMultiSet TreeMultiSets} are always sorted following a strict + * weak ordering criterion indicated by its internal comparison method (of {@link IComparable.less less}).

+ * + *

{@link TreeMultiSet} containers are generally slower than {@link HashMultiSet} containers + * to access individual elements by their key, but they allow the direct iteration on subsets based on + * their order.

+ * + *

{@link TreeMultiSet TreeMultiSets} are typically implemented as binary search trees.

+ * + *

+ *

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
+ * + *
Ordered
+ *
+ * The elements in the container follow a strict order at all times. All inserted elements are + * given a position in this order. + *
+ * + *
Set
+ *
The value of an element is also the key used to identify it.
+ * + *
Multiple equivalent keys
+ *
Multiple elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the elements. Each element in a {@link TreeMultiSet} container is also identified + * by this value (each value is itself also the element's key). + * + * @reference http://www.cplusplus.com/reference/set/multiset + * @author Jeongho Nam + */ + class TreeMultiSet extends base.MultiSet implements base.ITreeSet { + /** + * @hidden + */ + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (x: T, y: T) => boolean); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + */ + constructor(array: Array); + /** + * Contruct from elements with compare. + * + * @param array Elements to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array, compare: (x: T, y: T) => boolean); + /** + * Copy Constructor. + */ + constructor(container: TreeMultiSet); + /** + * Copy Constructor with compare. + * + * @param container A container to be copied. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: TreeMultiSet, compare: (x: T, y: T) => boolean); + /** + * Range Constructor. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * Construct from range and compare. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * @param compare A binary predicate determines order of elements. + */ + constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(val: T): SetIterator; + /** + * @inheritdoc + */ + count(val: T): number; + /** + * @inheritdoc + */ + key_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + lower_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + upper_bound(val: T): SetIterator; + /** + * @inheritdoc + */ + equal_range(val: T): Pair, SetIterator>; + /** + * @hidden + */ + protected _Insert_by_val(val: T): any; + /** + * @hidden + */ + protected _Insert_by_hint(hint: SetIterator, val: T): SetIterator; + /** + * @hidden + */ + protected _Insert_by_range>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: SetIterator, last: SetIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: SetIterator, last: SetIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link TreeMultiSet set} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link TreeMultiSet set container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link TreeMultiSet container}. + */ + swap(obj: TreeMultiSet): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + } +} +declare namespace std.TreeMultiMap { + type iterator = std.MapIterator; + type reverse_iterator = std.MapReverseIterator; +} +declare namespace std { + /** + *

Tree-structured multiple-key map.

+ * + *

{@link TreeMultiMap TreeMultiMaps} are associative containers that store elements formed by a combination of + * a key value and a mapped value, following a specific order, and where multiple elements can + * have equivalent keys.

+ * + *

In a {@link TreeMultiMap}, the key values are generally used to sort and uniquely identify + * the elements, while the mapped values store the content associated to this key. The types of + * key and mapped value may differ, and are grouped together in member type + * value_type, which is a {@link Pair} type combining both:

+ * + *

typedef Pair value_type;

+ * + *

Internally, the elements in a {@link TreeMultiMap}are always sorted by its key following a + * strict weak ordering criterion indicated by its internal comparison method (of {@link less}).

+ * + *

{@link TreeMultiMap}containers are generally slower than {@link HashMap} containers + * to access individual elements by their key, but they allow the direct iteration on subsets based + * on their order.

+ * + *

{@link TreeMultiMap TreeMultiMaps} are typically implemented as binary search trees.

+ * + *

< + * img src="http://samchon.github.io/typescript-stl/images/design/class_diagram/map_containers.png" style="max-width: 100%" />

+ * + *

Container properties

+ *
+ *
Associative
+ *
+ * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. + *
+ * + *
Ordered
+ *
+ * The elements in the container follow a strict order at all times. All inserted elements are + * given a position in this order. + *
+ * + *
Map
+ *
+ * Each element associates a key to a mapped value: + * Keys are meant to identify the elements whose main content is the mapped value. + *
+ * + *
Multiple equivalent keys
+ *
Multiple elements in the container can have equivalent keys.
+ *
+ * + * @param Type of the keys. Each element in a map is uniquely identified by its key value. + * @param Type of the mapped value. Each element in a map stores some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/map/multimap + * @author Jeongho Nam + */ + class TreeMultiMap extends base.MultiMap implements base.ITreeMap { + /** + * @hidden + */ + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (x: Key, y: Key) => boolean); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + */ + constructor(array: Array>); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array>, compare: (x: Key, y: Key) => boolean); + /** + * Contruct from tuples. + * + * @param array Tuples to be contained. + */ + constructor(array: Array<[Key, T]>); + /** + * Contruct from tuples. + * + * @param array Tuples to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array<[Key, T]>, compare: (x: Key, y: Key) => boolean); + /** + * Copy Constructor. + * + * @param container Another map to copy. + */ + constructor(container: TreeMultiMap); + /** + * Copy Constructor. + * + * @param container Another map to copy. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: TreeMultiMap, compare: (x: Key, y: Key) => boolean); + /** + * Range Constructor. + * + * @param begin nput interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator>, end: Iterator>); + /** + * Range Constructor. + * + * @param begin nput interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * @param compare A binary predicate determines order of elements. + */ + constructor(begin: Iterator>, end: Iterator>, compare: (x: Key, y: Key) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: Key): MapIterator; + /** + * @inheritdoc + */ + count(key: Key): number; + /** + * @inheritdoc + */ + key_comp(): (x: Key, y: Key) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: Pair, y: Pair) => boolean; + /** + * @inheritdoc + */ + lower_bound(key: Key): MapIterator; + /** + * @inheritdoc + */ + upper_bound(key: Key): MapIterator; + /** + * @inheritdoc + */ + equal_range(key: Key): Pair, MapIterator>; + /** + * @hidden + */ + protected _Insert_by_pair(pair: Pair): any; + /** + * @hidden + */ + protected _Insert_by_hint(hint: MapIterator, pair: Pair): MapIterator; + /** + * @hidden + */ + protected _Insert_by_range>>(first: InputIterator, last: InputIterator): void; + /** + * @inheritdoc + */ + protected _Handle_insert(first: MapIterator, last: MapIterator): void; + /** + * @inheritdoc + */ + protected _Handle_erase(first: MapIterator, last: MapIterator): void; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link TreeMapMulti map} of the same type. Sizes abd container type may differ.

+ * + *

After the call to this member function, the elements in this container are those which were + * in obj before the call, and the elements of obj are those which were in this. All + * iterators, references and pointers remain valid for the swapped objects.

+ * + *

Notice that a non-member function exists with the same name, {@link std.swap swap}, overloading that + * algorithm with an optimization that behaves like this member function.

+ * + * @param obj Another {@link TreeMapMulti map container} of the same type of elements as this (i.e., + * with the same template parameters, Key and T) whose content is swapped + * with that of this {@link TreeMapMulti container}. + */ + swap(obj: TreeMultiMap): void; + /** + * @inheritdoc + */ + swap(obj: base.IContainer>): void; + } +} +declare namespace std { + /** + *

System error exception.

+ * + *

This class defines the type of objects thrown as exceptions to report conditions originating during + * runtime from the operating system or other low-level application program interfaces which have an + * associated {@link ErrorCode}.

+ * + *

The class inherits from {@link RuntimeError}, to which it adds an {@link ErrorCode} as + * member code (and defines a specialized what member).

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/system_error/system_error + * @author Jeongho Nam + */ + class SystemError extends RuntimeError { + /** + * @hidden + */ + protected code_: ErrorCode; + /** + * Construct from an error code. + * + * @param code An {@link ErrorCode} object. + */ + constructor(code: ErrorCode); + /** + * Construct from an error code and message. + * + * @param code An {@link ErrorCode} object. + * @param message A message incorporated in the string returned by member {@link what what()}. + */ + constructor(code: ErrorCode, message: string); + /** + * Construct from a numeric value and error category. + * + * @param val A numerical value identifying an error code. + * @param category A reference to an {@link ErrorCode} object. + */ + constructor(val: number, category: ErrorCategory); + /** + * Construct from a numeric value, error category and message. + * + * @param val A numerical value identifying an error code. + * @param category A reference to an {@link ErrorCode} object. + * @param message A message incorporated in the string returned by member {@link what what()}. + */ + constructor(val: number, category: ErrorCategory, message: string); + /** + *

Get error code.

+ * + *

Returns the {@link ErrorCode} object associated with the exception.

+ * + *

This value is either the {@link ErrorCode} passed to the construction or its equivalent + * (if constructed with a value and a {@link category}.

+ * + * @return The {@link ErrorCode} associated with the object. + */ + code(): ErrorCode; + } +} +declare namespace std { + /** + *

Error category.

+ * + *

This type serves as a base class for specific category types.

+ * + *

Category types are used to identify the source of an error. They also define the relation between + * {@link ErrorCode} and {@link ErrorCondition}objects of its category, as well as the message set for {@link ErrorCode} + * objects. + * + *

Objects of these types have no distinct values and are not-copyable and not-assignable, and thus can only be + * passed by reference. As such, only one object of each of these types shall exist, each uniquely identifying its own + * category: all error codes and conditions of a same category shall return a reference to same object.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/system_error/error_category + * @author Jeongho Nam + */ + abstract class ErrorCategory { + /** + * Default Constructor. + */ + constructor(); + /** + *

Return category name.

+ * + *

In derived classes, the function returns a string naming the category.

+ * + *

In {@link ErrorCategory}, it is a pure virtual member function.

+ * + *
    + *
  • In the {@link GenericCategory} object, it returns "generic".
  • + *
  • In the {@link SystemCategory} object, it returns "system".
  • + *
  • In the {@link IOStreamCategory} object, it returns "iostream".
  • + *
+ * + * @return The category name. + */ + abstract name(): string; + /** + *

Error message.

+ * + *

In derived classes, the function returns a string object with a message describing the error condition + * denoted by val.

+ * + *

In {@link ErrorCategory}, it is a pure virtual member function.

+ * + *

This function is called both by {@link ErrorCode.message ErrorCode.message()} and + * {@link ErrorCondition.message ErrorCondition.message()} to obtain the corresponding message in the + * {@link category}. Therefore, numerical values used by custom error codes and + * {@link ErrorCondition error conditions} should only match for a category if they describe the same error.

+ * + * @param val A numerical value identifying an error condition. + * If the {@link ErrorCategory} object is the {@link GenericCategory}, this argument is equivalent to an + * {@link errno} value. + * + * @return A string object with the message. + */ + abstract message(val: number): string; + /** + *

Default error condition.

+ * + *

Returns the default {@link ErrorCondition}object of this category that is associated with the + * {@link ErrorCode} identified by a value of val.

+ * + *

Its definition in the base class {@link ErrorCategory} returns the same as constructing an + * {@link ErrorCondition} object with: + * + *

new ErrorCondition(val, *this);

+ * + *

As a virtual member function, this behavior can be overriden in derived classes.

+ * + *

This function is called by the default definition of member {@link equivalent equivalent()}, which is used to + * compare {@link ErrorCondition error conditions} with error codes.

+ * + * @param val A numerical value identifying an error condition. + * + * @return The default {@link ErrorCondition}object associated with condition value val for this category. + */ + default_error_condition(val: number): ErrorCondition; + /** + *

Check error code equivalence.

+ * + *

Checks whether, for the category, an {@link ErrorCode error code} is equivalent to an + * {@link ErrorCondition error condition.

+ * + *

This function is called by the overloads of comparison operators when an {@link ErrorCondition} object is + * compared to an {@link ErrorCode} object to check for equality or inequality. If either one of those objects' + * {@link ErrorCategory categories} considers the other equivalent using this function, they are considered + * equivalent by the operator.

+ * + *

As a virtual member function, this behavior can be overridden in derived classes to define a different + * correspondence mechanism for each {@link ErrorCategory} type.

+ * + * @param val_code A numerical value identifying an error code. + * @param cond An object of an {@link ErrorCondition} type. + * + * @return true if the arguments are considered equivalent. false otherwise. + */ + equivalent(val_code: number, cond: ErrorCondition): boolean; + /** + *

Check error code equivalence.

+ * + *

Checks whether, for the category, an {@link ErrorCode error code} is equivalent to an + * {@link ErrorCondition error condition.

+ * + *

This function is called by the overloads of comparison operators when an {@link ErrorCondition} object is + * compared to an {@link ErrorCode} object to check for equality or inequality. If either one of those objects' + * {@link ErrorCategory categories} considers the other equivalent using this function, they are considered + * equivalent by the operator.

+ * + *

As a virtual member function, this behavior can be overridden in derived classes to define a different + * correspondence mechanism for each {@link ErrorCategory} type.

+ * + * @param code An object of an {@link ErrorCode} type. + * @param val_cond A numerical value identifying an error code. + * + * @return true if the arguments are considered equivalent. false otherwise. + */ + equivalent(code: ErrorCode, val_cond: number): boolean; + } +} +declare namespace std { + /** + *

Error condition.

+ * + *

Objects of this type hold a condition {@link value} associated with a {@link category}.

+ * + *

Objects of this type describe errors in a generic way so that they may be portable across different + * systems. This is in contrast with {@link ErrorCode} objects, that may contain system-specific + * information.

+ * + *

Because {@link ErrorCondition}objects can be compared with error_code objects directly by using + * relational operators, {@link ErrorCondition}objects are generally used to check whether + * a particular {@link ErrorCode} obtained from the system matches a specific error condition no matter + * the system.

+ * + *

The {@link ErrorCategory categories} associated with the {@link ErrorCondition} and the + * {@link ErrorCode} define the equivalences between them.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/system_error/error_condition + * @author Jeongho Nam + */ + class ErrorCondition extends base.ErrorInstance { + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from a numeric value and error category. + * + * @param val A numerical value identifying an error condition. + * @param category A reference to an {@link ErrorCategory} object. + */ + constructor(val: number, category: ErrorCategory); + } +} +declare namespace std { + /** + *

Error code.

+ * + *

Objects of this type hold an error code {@link value} associated with a {@link category}.

+ * + *

The operating system and other low-level applications and libraries generate numerical error codes to + * represent possible results. These numerical values may carry essential information for a specific platform, + * but be non-portable from one platform to another.

+ * + *

Objects of this class associate such numerical codes to {@link ErrorCategory error categories}, so that they + * can be interpreted when needed as more abstract (and portable) {@link ErrorCondition error conditions}.

+ * + *

+ *

+ * + * @reference http://www.cplusplus.com/reference/system_error/error_code + * @author Jeongho Nam + */ + class ErrorCode extends base.ErrorInstance { + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from a numeric value and error category. + * + * @param val A numerical value identifying an error code. + * @param category A reference to an {@link ErrorCategory} object. + */ + constructor(val: number, category: ErrorCategory); + } +} +declare namespace std { + /** + *

Running on Node.

+ * + *

Test whether the JavaScript is running on Node.

+ * + * @references http://stackoverflow.com/questions/17575790/environment-detection-node-js-or-browser + */ + function is_node(): boolean; + /** + *

Pair of values.

+ * + *

This class couples together a pair of values, which may be of different types (T1 and + * T2). The individual values can be accessed through its public members {@link first} and + * {@link second}.

+ * + * @param Type of member {@link first}. + * @param Type of member {@link second}. + * + * @reference http://www.cplusplus.com/reference/utility/pair + * @author Jeongho Nam + */ + class Pair { + /** + *

A first value in the Pair.

+ */ + first: T1; + /** + *

A second value in the Pair.

+ */ + second: T2; + /** + *

Construct from pair values.

+ * + * @param first The first value of the Pair + * @param second The second value of the Pair + */ + constructor(first: T1, second: T2); + /** + *

Whether a Pair is equal with the Pair.

+ *

Compare each first and second value of two Pair(s) and returns whether they are equal or not.

+ * + *

If stored key and value in a Pair are not number or string but an object like a class or struct, + * the comparison will be executed by a member method (SomeObject)::equal_to(). If the object does not have + * the member method equal_to(), only address of pointer will be compared.

+ * + * @param obj A Map to compare + * @return Indicates whether equal or not. + */ + equal_to(pair: Pair): boolean; + less(pair: Pair): boolean; + } + /** + *

Construct {@link Pair} object.

+ * + *

Constructs a {@link Pair} object with its {@link Pair.first first} element set to x and its + * {@link Pair.second second} element set to y.

+ * + *

The template types can be implicitly deduced from the arguments passed to {@link make_pair}.

+ * + *

{@link Pair} objects can be constructed from other {@link Pair} objects containing different types, if the + * respective types are implicitly convertible.

+ * + * @param x Value for member {@link Pair.first first}. + * @param y Value for member {@link Pair.second second}. + * + * @return A {@link Pair} object whose elements {@link Pair.first first} and {@link Pair.second second} are set to + * x and y respectivelly. + */ + function make_pair(x: T1, y: T2): Pair; +} +declare namespace std { + /** + *

Priority queue.

+ * + *

{@link PriorityQueue Priority queues} are a type of container adaptors, specifically designed such that its + * first element is always the greatest of the elements it contains, according to some strict weak ordering + * criterion.

+ * + *

This context is similar to a heap, where elements can be inserted at any moment, and only the + * max heap element can be retrieved (the one at the top in the {@link PriorityQueue priority queue}).

+ * + *

{@link PriorityQueue Priority queues} are implemented as container adaptors, which are classes that + * use an encapsulated object of a specific container class as its {@link container_ underlying container}, + * providing a specific set of member functions to access its elements. Elements are popped from the "back" + * of the specific container, which is known as the top of the {@link PriorityQueue Priority queue}.

+ * + *

The {@link container_ underlying container} may be any of the standard container class templates or some + * other specifically designed container class. The container shall be accessible through + * {@link IArrayIterator random access iterators} and support the following operations:

+ * + *
    + *
  • empty()
  • + *
  • size()
  • + *
  • front()
  • + *
  • push_back()
  • + *
  • pop_back()
  • + *
+ * + *

The standard container classes {@link Vector} and {@link Deque} fulfill these requirements. By default, if + * no container class is specified for a particular {@link PriorityQueue} class instantiation, the standard + * container {@link Vector} is used.

+ * + *

Support of {@link IArrayIterator random access iterators} is required to keep a heap structure internally + * at all times. This is done automatically by the container adaptor by automatically calling the algorithm + * functions make_heap, push_heap and pop_heap when needed.

+ * + * @param Type of the elements. + * + * @reference http://www.cplusplus.com/reference/queue/priority_queue/ + * @author Jeongho Nam + */ + class PriorityQueue { + /** + *

The underlying container for implementing the priority queue.

+ * + *

Following standard definition from the C++ committee, the underlying container should be one of + * {@link Vector} or {@link Deque}, however, I've adopted {@link TreeMultiSet} instead of them. Of course, + * there are proper reasons for adapting the {@link TreeMultiSet} even violating standard advice.

+ * + *

Underlying container of {@link PriorityQueue} must keep a condition; the highest (or lowest) + * element must be placed on the terminal node for fast retrieval and deletion. To keep the condition with + * {@link Vector} or {@link Deque}, lots of times will only be spent for re-arranging elements. It calls + * rearrangement functions like make_heap, push_heap and pop_head for rearrangement.

+ * + *

However, the {@link TreeMultiSet} container always keeps arrangment automatically without additional + * operations and it even meets full criteria of {@link PriorityQueue}. Those are the reason why I've adopted + * {@link TreeMultiSet} as the underlying container of {@link PriorityQueue}.

+ */ + private container_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (left: T, right: T) => boolean); + /** + * Contruct from elements. + * + * @param array Elements to be contained. + */ + constructor(array: Array); + /** + * Contruct from elements with compare. + * + * @param array Elements to be contained. + * @param compare A binary predicate determines order of elements. + */ + constructor(array: Array, compare: (left: T, right: T) => boolean); + /** + * Copy Constructor. + */ + constructor(container: base.IContainer); + /** + * Copy Constructor with compare. + * + * @param container A container to be copied. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: base.IContainer, compare: (left: T, right: T) => boolean); + /** + * Range Constructor. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + constructor(begin: Iterator, end: Iterator); + /** + * Range Constructor with compare. + * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + * @param compare A binary predicate determines order of elements. + */ + constructor(begin: Iterator, end: Iterator, compare: (left: T, right: T) => boolean); + /** + *

Return size.

+ * + *

Returns the number of elements in the {@link PriorityQueue}.

+ * + *

This member function effectively calls member {@link IArray.size size} of the + * {@link container_ underlying container} object.

+ * + * @return The number of elements in the underlying + */ + size(): number; + /** + *

Test whether container is empty.

+ * + *

Returns whether the {@link PriorityQueue} is empty: i.e. whether its {@link size} is zero.

+ * + *

This member function effectively calls member {@link IARray.empty empty} of the + * {@link container_ underlying container} object.

+ */ + empty(): boolean; + /** + *

Access top element.

+ * + *

Returns a constant reference to the top element in the {@link PriorityQueue}.

+ * + *

The top element is the element that compares higher in the {@link PriorityQueue}, and the next that is + * removed from the container when {@link PriorityQueue.pop} is called.

+ * + *

This member function effectively calls member {@link IArray.front front} of the + * {@link container_ underlying container} object.

+ * + * @return A reference to the top element in the {@link PriorityQueue}. + */ + top(): T; + /** + *

Insert element.

+ * + *

Inserts a new element in the {@link PriorityQueue}. The content of this new element is initialized to + * val. + * + *

This member function effectively calls the member function {@link IArray.push_back push_back} of the + * {@link container_ underlying container} object, and then reorders it to its location in the heap by calling + * the push_heap algorithm on the range that includes all the elements of the

+ * + * @param val Value to which the inserted element is initialized. + */ + push(val: T): void; + /** + *

Remove top element.

+ * + *

Removes the element on top of the {@link PriorityQueue}, effectively reducing its {@link size} by one. + * The element removed is the one with the highest (or lowest) value.

+ * + *

The value of this element can be retrieved before being popped by calling member + * {@link PriorityQueue.top}.

+ * + *

This member function effectively calls the pop_heap algorithm to keep the heap property of + * {@link PriorityQueue PriorityQueues} and then calls the member function {@link IArray.pop_back pop_back} of + * the {@link container_ underlying container} object to remove the element.

+ */ + pop(): void; + /** + *

Swap contents.

+ * + *

Exchanges the contents of the container adaptor by those of obj, swapping both the + * {@link container_ underlying container} value and their comparison function using the corresponding + * {@link std.swap swap} non-member functions (unqualified).

+ * + *

This member function has a noexcept specifier that matches the combined noexcept of the + * {@link IArray.swap swap} operations on the {@link container_ underlying container} and the comparison + * functions.

+ * + * @param obj {@link PriorityQueue} container adaptor of the same type (i.e., instantiated with the same + * template parameters, T). Sizes may differ. + */ + swap(obj: PriorityQueue): void; } }

This namespace declares an unspecified number of objects: _1, _2, _3, ..., which are + * used to specify placeholders in calls to function {@link std.bind}.

This namespace declares an unspecified number of objects: _1, _2, _3, ..., which are - * used to specify placeholders in calls to function {@link std.bind}.