diff --git a/typescript-stl/typescript-stl.d.ts b/typescript-stl/typescript-stl.d.ts index 36ad79e4a1..35bd397459 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.

* @@ -4434,8 +4445,8 @@ declare namespace std.base { * {@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

*
@@ -4580,7 +4591,6 @@ declare namespace std.base { * Return the number of elements in the map. */ size(): number; - protected _Get_data(): List>; /** * @inheritdoc */ @@ -4589,6 +4599,84 @@ declare namespace std.base { * @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.

* @@ -4596,7 +4684,9 @@ declare namespace std.base { * 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. + * @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}. @@ -4609,7 +4699,9 @@ declare namespace std.base { * 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. + * @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}. @@ -4753,12 +4845,12 @@ declare namespace std.base { /** *

Abstract method handling insertions for indexing.

* - *

This method, {@link handle_insert} is designed to register the first to last to somewhere storing + *

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 + * 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} @@ -4775,11 +4867,11 @@ declare namespace std.base { /** *

Abstract method handling deletions for indexing.

* - *

This method, {@link handle_insert} is designed to unregister the first to last to somewhere storing + *

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 + * 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} @@ -4803,8 +4895,8 @@ declare namespace std { /** *

An iterator of {@link MapContainer map container}.

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ @@ -4874,8 +4966,8 @@ declare namespace std { /** *

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

* - *

- *

+ *

+ *

* * @author Jeongho Nam */ @@ -4922,8 +5014,8 @@ declare namespace std.base { * {@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

*
@@ -5019,6 +5111,55 @@ declare namespace std.base { * @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.

* @@ -5032,7 +5173,9 @@ declare namespace std.base { * *

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

* - * @param pair {@link Pair} to be inserted as an element. + * @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 @@ -5198,13 +5341,49 @@ declare namespace std.base { * @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 {@link Pair} to be inserted as an element. + * @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. */ @@ -5459,8 +5638,8 @@ declare namespace std { *

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

@@ -5744,10 +5923,6 @@ declare namespace std.base { * @inheritdoc */ size(): number; - /** - * @hidden - */ - _Get_data(): List; /** * @inheritdoc */ @@ -5854,12 +6029,12 @@ declare namespace std.base { /** *

Abstract method handling insertions for indexing.

* - *

This method, {@link handle_insert} is designed to register the first to last to somewhere storing + *

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 + * 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} @@ -5876,11 +6051,11 @@ declare namespace std.base { /** *

Abstract method handling deletions for indexing.

* - *

This method, {@link handle_insert} is designed to unregister the first to last to somewhere storing + *

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 + * 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} @@ -7166,8 +7341,17 @@ declare namespace std { * @author Jeongho Nam */ class ListIterator extends Iterator { + /** + * @hidden + */ private prev_; + /** + * @hidden + */ private next_; + /** + * @hidden + */ private value_; /** *

Construct from the source {@link List container}.

@@ -7204,14 +7388,6 @@ declare namespace std { * @param val Value to set. */ value: T; - /** - * @hidden - */ - _Set_prev(it: ListIterator): void; - /** - * @hidden - */ - _Set_next(it: ListIterator): void; /** * @inheritdoc */ @@ -8615,10 +8791,6 @@ declare namespace std { * @inheritdoc */ equal_range(val: T): Pair, SetIterator>; - /** - * @hidden - */ - _Get_tree(): base.AtomicTree; /** * @hidden */ @@ -11440,7 +11612,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 +11912,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>; /**