From c2b4e013e464715c74e3d6722f98a3bff597d2b8 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Sat, 18 Jun 2016 22:34:42 +0900 Subject: [PATCH 1/4] TypeScript-STL v1.0.0-rc.1 --- typescript-stl/typescript-stl.d.ts | 13423 +++++++++++++++------------ 1 file changed, 7356 insertions(+), 6067 deletions(-) diff --git a/typescript-stl/typescript-stl.d.ts b/typescript-stl/typescript-stl.d.ts index 1286a62084..0ef62635e8 100644 --- a/typescript-stl/typescript-stl.d.ts +++ b/typescript-stl/typescript-stl.d.ts @@ -1,4 +1,4 @@ -// Type definitions for TypeScript-STL v0.9.9 +// Type definitions for TypeScript-STL v1.0.0-rc.1 // Project: https://github.com/samchon/stl // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -19,7 +19,143 @@ // ------------------------------------------------------------------------------------ /** - * STL (Standard Template Library) Containers for TypeScript. + *

TypeScript-STL

+ *

+ *

+ * + *

GitHub Repository: https://github.com/samchon/stl

+ * + * + *

Introduction

+ *

STL (Standard Template Library) Containers and Algorithms for TypeScript.

+ * + *

TypeScript-STL is a TypeScript's Standard Template Library who is migrated from C++ STL. Most of classes + * and functions of STL have implemented. Just enjoy it.

+ * + *

Abstract Containers

+ * + *

Containers

+ * + * + *

Global Functions

+ * + * + * + *

References

+ *

You can learn and explore about TypeScript-STL more deeply with such below:

+ * + * + * + *

Installation

+ *

Node

+ * npm install -g typescript-stl + * + *
TypeScript
+ * + * // SOMEWHERE PLACE NODE AND STL HEADERS EXIST + * /// + * /// + * + * global["std"] = require("typescript-stl"); + * let list: std.List = new std.List(); + * + * + *
Pure JavaScript
+ * + * var std = require("typescript-stl"); + * var list = new std.List(); + * + * + *

Browser

+ *
In HTML Document
+ * + *
TypeScript, reference difinitions (header)
+ * + * /// + * + * + * + *

Index of Guidance, Wiki

+ * * * @author Jeongho Nam */ @@ -39,6 +175,2739 @@ declare namespace std.base { */ declare namespace std.example { } +declare namespace std { + /** + *

Apply function to range.

+ * + *

Applies function fn to each of the elements in the range [first, last).

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @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; + /** + *

Test condition on all elements in range.

+ * + *

Returns true if pred returns true for all the elements in the range + * [first, last) or if the range is {@link IContainer.empty empty}, and false otherwise. + *

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to + * boolean. The value returned indicates whether the element fulfills the condition + * checked by this function. The function shall not modify its argument. + * + * @return true if pred returns true for all the elements in the range or if the range is + * {@link IContainer.empty empty}, and false otherwise. + */ + function all_of>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; + /** + *

Test if any element in range fulfills condition.

+ * + *

Returns true if pred returns true for any of the elements in the range + * [first, last), and false otherwise.

+ * + *

If [first, last) is an {@link IContainer.empty empty} range, the function returns + * false.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to + * boolean. The value returned indicates whether the element fulfills the condition + * checked by this function. The function shall not modify its argument. + * + * @return true if pred returns true for any of the elements in the range + * [first, last), and false otherwise. If [first, last) is an + * {@link IContainer.empty empty} range, the function returns false. + */ + function any_of>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; + /** + *

Test if no elements fulfill condition.

+ * + *

Returns true if pred returns false for all the elements in the range + * [first, last) or if the range is {@link IContainer.empty empty}, and false otherwise. + *

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to + * boolean. The value returned indicates whether the element fulfills the condition + * checked by this function. The function shall not modify its argument. + * + * @return true if pred returns false for all the elements in the range + * [first, last) or if the range is {@link IContainer.empty empty}, and false + * otherwise. + */ + function none_of>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; + /** + *

Test whether the elements in two ranges are equal.

+ * + *

Compares the elements in the range [first1, last1) with those in the range beginning at + * first2, and returns true if all of the elements in both ranges match.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to + * as many elements of this sequence as those in the range [first1, last1). + * + * @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; + /** + *

Test whether the elements in two ranges are equal.

+ * + *

Compares the elements in the range [first1, last1) with those in the range beginning at + * first2, and returns true if all of the elements in both ranges match.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to + * as many elements of this sequence as those in the range [first1, last1). + * @param pred Binary function that accepts two elements as argument (one of each of the two sequences, in the same + * order), and returns a value convertible to bool. The value returned indicates whether + * the elements are considered to match in the context of this function. + * + * @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; + /** + *

Test whether range is permutation of another.

+ * + *

Compares the elements in the range [first1, last1) with those in the range beginning at + * first2, and returns true if all of the elements in both ranges match, even in a different + * order.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to + * as many elements of this sequence as those in the range [first1, last1). + * + * @return true if all the elements in the range [first1, last1) compare equal to those + * of the range starting at first2 in any order, and false otherwise. + */ + function is_permutation, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2): boolean; + /** + *

Test whether range is permutation of another.

+ * + *

Compares the elements in the range [first1, last1) with those in the range beginning at + * first2, and returns true if all of the elements in both ranges match, even in a different + * order.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to + * as many elements of this sequence as those in the range [first1, last1). + * @param pred Binary function that accepts two elements as argument (one of each of the two sequences, in the same + * order), and returns a value convertible to bool. The value returned indicates whether + * the elements are considered to match in the context of this function. + * + * @return true if all the elements in the range [first1, last1) compare equal to those + * of the range starting at first2 in any order, and false otherwise. + */ + function is_permutation, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, pred: (x: T, y: T) => boolean): boolean; + /** + *

Lexicographical less-than comparison.

+ * + *

Returns true if the range [first1, last1) compares lexicographically less + * than the range [first2, last2).

+ * + *

A lexicographical comparison is the kind of comparison generally used to sort words alphabetically in + * dictionaries; It involves comparing sequentially the elements that have the same position in both ranges against + * each other until one element is not equivalent to the other. The result of comparing these first non-matching + * elements is the result of the lexicographical comparison.

+ * + *

If both sequences compare equal until one of them ends, the shorter sequence is lexicographically less + * than the longer one.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. + * @param last2 An {@link Iterator} to the final position of the second sequence. The ranged used is + * [first2, last2). + * + * @return true if the first range compares lexicographically less than than the second. + * false otherwise (including when all the elements of both ranges are equivalent). + */ + function lexicographical_compare, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): boolean; + /** + *

Lexicographical comparison.

+ * + *

Returns true if the range [first1, last1) compares lexicographically + * relationship than the range [first2, last2).

+ * + *

A lexicographical comparison is the kind of comparison generally used to sort words alphabetically in + * dictionaries; It involves comparing sequentially the elements that have the same position in both ranges against + * each other until one element is not equivalent to the other. The result of comparing these first non-matching + * elements is the result of the lexicographical comparison.

+ * + *

If both sequences compare equal until one of them ends, the shorter sequence is lexicographically + * relationship than the longer one.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. + * @param last2 An {@link Iterator} to the final position of the second sequence. The ranged used is + * [first2, last2). + * @param compare Binary function that accepts two arguments of the types pointed by the iterators, and returns a + * value convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. + * + * @return true if the first range compares lexicographically relationship than than the + * second. false otherwise (including when all the elements of both ranges are equivalent). + */ + function lexicographical_compare, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, compare: (x: T, y: T) => boolean): boolean; + /** + *

Find value in range.

+ * + *

Returns an iterator to the first element in the range [first, last) that compares equal to + * val. If no such element is found, the function returns last.

+ * + *

The function uses {@link equal_to equal_to} to compare the individual elements to val.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param val Value to search for in the range. + * + * @return An {@link Iterator} to the first element in the range that compares equal to val. If no elements + * match, the function returns last. + */ + function find>(first: InputIterator, last: InputIterator, val: T): InputIterator; + /** + *

Find element in range.

+ * + *

Returns an iterator to the first element in the range [first, last) for which pred returns + * true. If no such element is found, the function returns last.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument and returns a value convertible + * to bool. The value returned indicates whether the element is considered a match in + * the context of this function. The function shall not modify its argument. + * + * @return An {@link Iterator} to the first element in the range for which pred does not return + * false. If pred is false for all elements, the function returns + * last. + */ + function find_if>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): InputIterator; + /** + *

Find element in range.

+ * + *

Returns an iterator to the first element in the range [first, last) for which pred returns + * true. If no such element is found, the function returns last.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument and returns a value convertible + * to bool. The value returned indicates whether the element is considered a match in + * the context of this function. The function shall not modify its argument. + * + * @return An {@link Iterator} to the first element in the range for which pred returns false. + * If pred is true for all elements, the function returns last. + */ + function find_if_not>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): InputIterator; + /** + *

Find last subsequence in range.

+ * + *

Searches the range [first1, last1) for the last occurrence of the sequence defined by + * [first2, last2), and returns an {@link Iterator} to its first element, or last1,/i> if no + * occurrences are found.

+ * + *

The elements in both ranges are compared sequentially using {@link equal_to}: A subsequence of + * [first1, last1) is considered a match only when this is true for all the elements of + * [first2, last2).

+ * + *

This function returns the last of such occurrences. For an algorithm that returns the first instead, see + * {@link search}.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. + * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used + * is [first2, last2). + * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the + * same order), and returns a value convertible to bool. The value returned indicates + * whether the elements are considered to match in the context of this function. + * + * @return An {@link Iterator} to the first element of the last occurrence of [first2, last2) in + * [first1, last1). If the sequence is not found, the function returns ,i>last1
. Otherwise + * [first2, last2) is an empty range, the function returns last1. + */ + function find_end, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): Iterator1; + /** + *

Find last subsequence in range.

+ * + *

Searches the range [first1, last1) for the last occurrence of the sequence defined by + * [first2, last2), and returns an {@link Iterator} to its first element, or last1,/i> if no + * occurrences are found.

+ * + *

The elements in both ranges are compared sequentially using pred: A subsequence of + * [first1, last1) is considered a match only when this is true for all the elements of + * [first2, last2).

+ * + *

This function returns the last of such occurrences. For an algorithm that returns the first instead, see + * {@link search}.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. + * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used + * is [first2, last2). + * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the + * same order), and returns a value convertible to bool. The value returned indicates + * whether the elements are considered to match in the context of this function. + * + * @return An {@link Iterator} to the first element of the last occurrence of [first2, last2) in + * [first1, last1). If the sequence is not found, the function returns ,i>last1
. Otherwise + * [first2, last2) is an empty range, the function returns last1. + */ + function find_end, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, pred: (x: T, y: T) => boolean): Iterator1; + /** + *

Find element from set in range.

+ * + *

Returns an iterator to the first element in the range [first1, last1) that matches any of the + * elements in [first2, last2). If no such element is found, the function returns last1.

+ * + *

The elements in [first1, last1) are sequentially compared to each of the values in + * [first2, last2) using {@link equal_to}, until a pair matches.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. + * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used + * is [first2, last2). + * + * @return An {@link Iterator} to the first element in [first1, last1) that is part of + * [first2, last2). If no matches are found, the function returns last1. + */ + function find_first_of, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): Iterator1; + /** + *

Find element from set in range.

+ * + *

Returns an iterator to the first element in the range [first1, last1) that matches any of the + * elements in [first2, last2). If no such element is found, the function returns last1.

+ * + *

The elements in [first1, last1) are sequentially compared to each of the values in + * [first2, last2) using pred, until a pair matches.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. + * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used + * is [first2, last2). + * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the + * same order), and returns a value convertible to bool. The value returned indicates + * whether the elements are considered to match in the context of this function. + * + * @return An {@link Iterator} to the first element in [first1, last1) that is part of + * [first2, last2). If no matches are found, the function returns last1. + */ + function find_first_of, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, pred: (x: T, y: T) => boolean): Iterator1; + /** + *

Find equal adjacent elements in range.

+ * + *

Searches the range [first, last) for the first occurrence of two consecutive elements that match, + * and returns an {@link Iterator} to the first of these two elements, or last if no such pair is found.

+ * + *

Two elements match if they compare equal using {@link equal_to}.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * + * @return An {@link Iterator} to the first element of the first pair of matching consecutive elements in the range + * [first, last). If no such pair is found, the function returns last. + */ + function adjacent_find>(first: InputIterator, last: InputIterator): InputIterator; + /** + *

Find equal adjacent elements in range.

+ * + *

Searches the range [first, last) for the first occurrence of two consecutive elements that match, + * and returns an {@link Iterator} to the first of these two elements, or last if no such pair is found.

+ * + *

Two elements match if they compare equal using pred.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to + * bool. The value returned indicates whether the element is considered a match in the + * context of this function. The function shall not modify its argument. + * + * @return An {@link Iterator} to the first element of the first pair of matching consecutive elements in the range + * [first, last). If no such pair is found, the function returns last. + */ + function adjacent_find>(first: InputIterator, last: InputIterator, pred: (x: T, y: T) => boolean): InputIterator; + /** + *

Search range for subsequence.

+ * + *

Searches the range [first1, last1) for the first occurrence of the sequence defined by + * [first2, last2), and returns an iterator to its first element, or last1 if no occurrences are + * found.

+ * + *

The elements in both ranges are compared sequentially using {@link equal_to}: A subsequence of + * [first1, last1) is considered a match only when this is true for all the elements of + * [first2, last2).

+ * + *

This function returns the first of such occurrences. For an algorithm that returns the last instead, see + * {@link find_end}.

+ * + * @param first1 {@link Iterator Forward iterator} to the initial position of the searched sequence. + * @param last1 {@link Iterator Forward iterator} to the final position of the searched sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Forward iterator} to the initial position of the sequence to be searched for. + * @param last2 {@link Iterator Forward iterator} to the final position of the sequence to be searched for. The range + * used is [first2, last2). + * + * @return An iterator to the first element of the first occurrence of [first2, last2) in first1 + * and last1. If the sequence is not found, the function returns last1. Otherwise + * [first2, last2) is an empty range, the function returns first1. + */ + function search, ForwardIterator2 extends Iterator>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2, last2: ForwardIterator2): ForwardIterator1; + /** + *

Search range for subsequence.

+ * + *

Searches the range [first1, last1) for the first occurrence of the sequence defined by + * [first2, last2), and returns an iterator to its first element, or last1 if no occurrences are + * found.

+ * + *

The elements in both ranges are compared sequentially using pred: A subsequence of + * [first1, last1) is considered a match only when this is true for all the elements of + * [first2, last2).

+ * + *

This function returns the first of such occurrences. For an algorithm that returns the last instead, see + * {@link find_end}.

+ * + * @param first1 {@link Iterator Forward iterator} to the initial position of the searched sequence. + * @param last1 {@link Iterator Forward iterator} to the final position of the searched sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Forward iterator} to the initial position of the sequence to be searched for. + * @param last2 {@link Iterator Forward iterator} to the final position of the sequence to be searched for. The range + * used is [first2, last2). + * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the same + * order), and returns a value convertible to bool. The returned value indicates whether the elements are + * considered to match in the context of this function. The function shall not modify any of its + * arguments. + * + * @return An iterator to the first element of the first occurrence of [first2, last2) in + * [first1, last1). If the sequence is not found, the function returns last1. Otherwise + * [first2, last2) is an empty range, the function returns first1. + */ + function search, ForwardIterator2 extends Iterator>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2, last2: ForwardIterator2, pred: (x: T, y: T) => boolean): ForwardIterator1; + /** + *

Search range for elements.

+ * + *

Searches the range [first, last) for a sequence of count elements, each comparing equal to + * val.

+ * + *

The function returns an iterator to the first of such elements, or last if no such sequence is found. + *

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the searched sequence. + * @param last {@link Iterator Forward iterator} to the final position of the searched 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. + * @param count Minimum number of successive elements to match. + * @param val Individual value to be compared, or to be used as argument for {@link equal_to}. + * + * @return An iterator to the first element of the sequence. If no such sequence is found, the function returns + * last. + */ + function search_n>(first: ForwardIterator, last: ForwardIterator, count: number, val: T): ForwardIterator; + /** + *

Search range for elements.

+ * + *

Searches the range [first, last) for a sequence of count elements, each comparing equal to + * val.

+ * + *

The function returns an iterator to the first of such elements, or last if no such sequence is found. + *

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the searched sequence. + * @param last {@link Iterator Forward iterator} to the final position of the searched 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. + * @param count Minimum number of successive elements to match. + * @param val Individual value to be compared, or to be used as argument for pred. + * @param pred Binary function that accepts two arguments (one element from the sequence as first, and val as + * second), and returns a value convertible to bool. The value returned indicates whether the + * element is considered a match in the context of this function. The function shall not modify any of its + * arguments. + * + * @return An {@link Iterator} to the first element of the sequence. If no such sequence is found, the function + * returns last. + */ + function search_n>(first: ForwardIterator, last: ForwardIterator, count: number, val: T, pred: (x: T, y: T) => boolean): ForwardIterator; + /** + *

Return first position where two ranges differ.

+ * + *

Compares the elements in the range [first1, last1) with those in the range beginning at + * first2, and returns the first element of both sequences that does not match.

+ * + *

The function returns a {@link Pair} of {@link iterators Iterator} to the first element in each range that + * does not match.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to + * as many elements of this sequence as those in the range [first1, last1). + * + * @return A {@link Pair}, where its members {@link Pair.first first} and {@link Pair.second second} point to the + * first element in both sequences that did not compare equal to each other. If the elements compared in + * both sequences have all matched, the function returns a {@link Pair} with {@link Pair.first first} set + * to last1 and {@link Pair.second second} set to the element in that same relative position in the + * second sequence. If none matched, it returns {@link make_pair}(first1, first2). + */ + function mismatch, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2): Pair; + /** + *

Return first position where two ranges differ.

+ * + *

Compares the elements in the range [first1, last1) with those in the range beginning at + * first2, and returns the first element of both sequences that does not match.

+ * + *

The function returns a {@link Pair} of {@link iterators Iterator} to the first element in each range that + * does not match.

+ * + * @param first1 An {@link Iterator} to the initial position of the first sequence. + * @param last1 An {@link Iterator} to the final position in a sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to + * as many elements of this sequence as those in the range [first1, last1). + * @param pred Binary function that accepts two elements as argument (one of each of the two sequences, in the same + * order), and returns a value convertible to bool. The value returned indicates whether + * the elements are considered to match in the context of this function. + * + * @return A {@link Pair}, where its members {@link Pair.first first} and {@link Pair.second second} point to the + * first element in both sequences that did not compare equal to each other. If the elements compared in + * both sequences have all matched, the function returns a {@link Pair} with {@link Pair.first first} set + * to last1 and {@link Pair.second second} set to the element in that same relative position in the + * second sequence. If none matched, it returns {@link make_pair}(first1, first2). + */ + function mismatch, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, compare: (x: T, y: T) => boolean): Pair; + /** + *

Count appearances of value in range.

+ * + *

Returns the number of elements in the range [first, last) that compare equal to val.

+ * + *

The function uses {@link equal_to} to compare the individual elements to val.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param val Value to match. + * + * @return The number of elements in the range [first, last) that compare equal to val. + */ + function count>(first: InputIterator, last: InputIterator, val: T): number; + /** + *

Return number of elements in range satisfying condition.

+ * + *

Returns the number of elements in the range [first, last) for which pred is true. + *

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible + * to bool. The value returned indicates whether the element is counted by this function. + * The function shall not modify its argument. This can either be a function pointer or a function + * object. + */ + function count_if>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): number; +} +declare namespace std { + /** + *

Copy range of elements.

+ * + *

Copies the elements in the range [first, last) into the range beginning at result.

+ * + *

The function returns an iterator to the end of the destination range (which points to the element following the + * last element copied).

+ * + *

The ranges shall not overlap in such a way that result points to an element in the range + * [first, last). For such cases, see {@link copy_backward}.

+ * + * @param first {@link Iterator Input iterator} to the initial position in a sequence to be copied. + * @param last {@link Iterator Input iterator} to the initial position in a sequence to be copied. 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. + * @param result {@link Iterator Output iterator} to the initial position in the destination sequence. This shall not + * point to any element in the range [first, last). + * + * @return An iterator to the end of the destination range where elements have been copied. + */ + function copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator): OutputIterator; + /** + *

Copy elements.

+ * + *

Copies the first n elements from the range beginning at first into the range beginning at + * result.

+ * + *

The function returns an iterator to the end of the destination range (which points to one past the last element + * copied).

+ * + *

If n is negative, the function does nothing.

+ * + *

If the ranges overlap, some of the elements in the range pointed by result may have undefined but valid values. + *

+ * + * @param first {@link Iterator Input iterator} to the initial position in a sequence of at least n elements to + * be copied. InputIterator shall point to a type assignable to the elements pointed by + * OutputIterator. + * @param n Number of elements to copy. If this value is negative, the function does nothing. + * @param result {@link Iterator Output iterator} to the initial position in the destination sequence of at least + * n elements. This shall not point to any element in the range [first, last]. + * + * @return An iterator to the end of the destination range where elements have been copied. + */ + function copy_n, OutputIterator extends Iterator>(first: InputIterator, n: number, result: OutputIterator): OutputIterator; + /** + *

Copy certain elements of range.

+ * + *

Copies the elements in the range [first, last) for which pred returns true to the + * range beginning at result.

+ * + * @param first {@link Iterator Input iterator} to the initial position in a sequence to be copied. + * @param last {@link Iterator Input iterator} to the initial position in a sequence to be copied. 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. + * @param result {@link Iterator Output iterator} to the initial position in the destination sequence. This shall not + * point to any element in the range [first, last). + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element is to be copied (if + * true, it is copied). The function shall not modify any of its arguments. + * + * @return An iterator to the end of the destination range where elements have been copied. + */ + function copy_if, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (x: T) => boolean): OutputIterator; + /** + *

Copy range of elements backward.

+ * + *

Copies the elements in the range [first, last) starting from the end into the range terminating + * at result.

+ * + *

The function returns an iterator to the first element in the destination range.

+ * + *

The resulting range has the elements in the exact same order as [first, last). To reverse their + * order, see {@link reverse_copy}.

+ * + *

The function begins by copying *(last-1) into *(result-1), and then follows backward + * by the elements preceding these, until first is reached (and including it).

+ * + *

The ranges shall not overlap in such a way that result (which is the past-the-end element in the + * destination range) points to an element in the range (first,last]. For such cases, see {@link copy}.

+ * + * @param first {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. + * @param last {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. 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. + * @param result {@link Iterator Bidirectional iterator} to the initial position in the destination sequence. This + * shall not point to any element in the range [first, last). + * + * @return An iterator to the first element of the destination sequence where elements have been copied. + */ + function copy_backward, BidirectionalIterator2 extends Iterator>(first: BidirectionalIterator1, last: BidirectionalIterator1, result: BidirectionalIterator2): BidirectionalIterator2; + /** + *

Fill range with value.

+ * + *

Assigns val to all the elements in the range [first, last).

+ * + * @param first {@link Iterator Forward iterator} to the initial position in a sequence of elements that support being + * assigned a value of type T. + * @param last {@link Iterator Forward iterator} to the final position in a sequence of elements that support being + * assigned a value of type T.. The range filled 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. + * @param val Value to assign to the elements in the filled range. + */ + function fill>(first: ForwardIterator, last: ForwardIterator, val: T): void; + /** + *

Fill sequence with value.

+ * + *

Assigns val to the first n elements of the sequence pointed by first.

+ * + * @param first {@link Iterator Output iterator} to the initial position in a sequence of elements that support being + * assigned a value of type T. + * @param n Number of elements to fill. If negative, the function does nothing. + * @param val Value to be used to fill the range. + * + * @return An iterator pointing to the element that follows the last element filled. + */ + function fill_n>(first: OutputIterator, n: number, val: T): OutputIterator; + /** + *

Transform range.

+ * + *

Applies op to each of the elements in the range [first, last) and stores the value returned + * by each operation in the range that begins at result.

+ * + * @param first {@link Iterator Input iterator} to the initial position in a sequence to be transformed. + * @param last {@link Iterator Input iterator} to the initial position in a sequence to be transformed. 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. + * @param result {@link Iterator Output} iterator to the initial position of the range where the operation results are + * stored. The range includes as many elements as [first, last). + * @param op Unary function that accepts one element of the type pointed to by InputIterator as argument, and + * returns some result value convertible to the type pointed to by OutputIterator. + * + * @return An iterator pointing to the element that follows the last element written in the result sequence. + */ + function transform, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, op: (val: T) => T): OutputIterator; + /** + *

Transform range.

+ * + *

Calls binary_op using each of the elements in the range [first1, last1) as first argument, + * and the respective argument in the range that begins at first2 as second argument. The value returned by + * each call is stored in the range that begins at result.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second range. The range includes as + * many elements as [first1, last1). + * @param result {@link Iterator Output} iterator to the initial position of the range where the operation results are + * stored. The range includes as many elements as [first1, last1). + * @param binary_op Binary function that accepts two elements as argument (one of each of the two sequences), and + * returns some result value convertible to the type pointed to by OutputIterator. + * + * @return An iterator pointing to the element that follows the last element written in the result sequence. + */ + function transform, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, result: OutputIterator, binary_op: (x: T, y: T) => T): OutputIterator; + /** + *

Generate values for range with function.

+ * + *

Assigns the value returned by successive calls to gen to the elements in the range [first, last). + *

+ * + * @param first {@link Iterator Forward iterator} to the initial position in a sequence. + * @param last {@link Iterator Forward iterator} to the final position in a sequence. The range affected 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. + * @param gen Generator function that is called with no arguments and returns some value of a type convertible to + * those pointed by the iterators. + */ + function generate>(first: ForwardIterator, last: ForwardIterator, gen: () => T): void; + /** + *

Generate values for sequence with function.

+ * + *

Assigns the value returned by successive calls to gen to the first n elements of the sequence + * pointed by first.

+ * + * @param first {@link Iterator Output iterator} to the initial position in a sequence of at least n elements + * that support being assigned a value of the type returned by gen. + * @param n Number of values to generate. If negative, the function does nothing. + * @param gen Generator function that is called with no arguments and returns some value of a type convertible to + * those pointed by the iterators. + * + * @return An iterator pointing to the element that follows the last element whose value has been generated. + */ + function generate_n>(first: ForwardIterator, n: number, gen: () => T): ForwardIterator; + /** + *

Remove consecutive duplicates in range.

+ * + *

Removes all but the first element from every consecutive group of equivalent elements in the range + * [first, last).

+ * + *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot + * alter the size of an array or a container): The removal is done by replacing the duplicate elements by the next + * element that is not a duplicate, and signaling the new size of the shortened range by returning an iterator to + * the element that should be considered its new past-the-last element.

+ * + *

The relative order of the elements not removed is preserved, while the elements between the returned + * iterator and last are left in a valid but unspecified state.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * + * @return An iterator to the element that follows the last element not removed. The range between first and + * this iterator includes all the elements in the sequence that were not considered duplicates. + */ + function unique>(first: InputIterator, last: InputIterator): InputIterator; + /** + *

Remove consecutive duplicates in range.

+ * + *

Removes all but the first element from every consecutive group of equivalent elements in the range + * [first, last).

+ * + *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot + * alter the size of an array or a container): The removal is done by replacing the duplicate elements by the next + * element that is not a duplicate, and signaling the new size of the shortened range by returning an iterator to + * the element that should be considered its new past-the-last element.

+ * + *

The relative order of the elements not removed is preserved, while the elements between the returned + * iterator and last are left in a valid but unspecified state.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Binary function that accepts two elements in the range as argument, and returns a value convertible + * to bool. The value returned indicates whether both arguments are considered equivalent + * (if true, they are equivalent and one of them is removed). The function shall not modify + * any of its arguments. + * + * @return An iterator to the element that follows the last element not removed. The range between first and + * this iterator includes all the elements in the sequence that were not considered duplicates. + */ + function unique>(first: InputIterator, last: InputIterator, pred: (left: t, right: t) => boolean): InputIterator; + /** + *

Copy range removing duplicates.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, except + * consecutive duplicates (elements that compare equal to the element preceding).

+ * + *

Only the first element from every consecutive group of equivalent elements in the range + * [first, last) is copied.

+ * + *

The comparison between elements is performed by applying {@lnk equal_to}.

+ * + * @param first {@link Iterator Forward iterator} to the initial position in a sequence. + * @param last {@link Iterator Forward iterator} 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. + * @param result Output iterator to the initial position of the range where the resulting range of values is stored. + * The pointed type shall support being assigned the value of an element in the range + * [first, last). + * + * @return An iterator pointing to the end of the copied range, which contains no consecutive duplicates. + */ + function unique_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator): OutputIterator; + /** + *

Copy range removing duplicates.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, except + * consecutive duplicates (elements that compare equal to the element preceding).

+ * + *

Only the first element from every consecutive group of equivalent elements in the range + * [first, last) is copied.

+ * + *

The comparison between elements is performed by applying pred.

+ * + * @param first {@link Iterator Forward iterator} to the initial position in a sequence. + * @param last {@link Iterator Forward iterator} 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. + * @param result Output iterator to the initial position of the range where the resulting range of values is stored. + * The pointed type shall support being assigned the value of an element in the range + * [first, last). + * @param pred Binary function that accepts two elements in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether both arguments are considered equivalent (if + * true, they are equivalent and one of them is removed). The function shall not modify any + * of its arguments. + * + * @return An iterator pointing to the end of the copied range, which contains no consecutive duplicates. + */ + function unique_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (x: T, y: T) => boolean): OutputIterator; + /** + *

Remove value from range.

+ * + *

Transforms the range [first, last) into a range with all the elements that compare equal to + * val removed, and returns an iterator to the new last of that range.

+ * + *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot alter + * the size of an array or a container): The removal is done by replacing the elements that compare equal to + * val by the next element that does not, and signaling the new size of the shortened range by returning an + * iterator to the element that should be considered its new past-the-last element.

+ * + *

The relative order of the elements not removed is preserved, while the elements between the returned iterator + * and last are left in a valid but unspecified state.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param val Value to be removed. + */ + function remove>(first: InputIterator, last: InputIterator, val: T): InputIterator; + /** + *

Remove elements from range.

+ * + *

Transforms the range [first, last) into a range with all the elements for which pred returns + * true removed, and returns an iterator to the new last of that range.

+ * + *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot + * alter the size of an array or a container): The removal is done by replacing the elements for which pred returns + * true by the next element for which it does not, and signaling the new size of the shortened range + * by returning an iterator to the element that should be considered its new past-the-last element.

+ * + *

The relative order of the elements not removed is preserved, while the elements between the returned + * iterator and last are left in a valid but unspecified state.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element is to be removed (if + * true, it is removed). The function shall not modify its argument. + */ + function remove_if>(first: InputIterator, last: InputIterator, pred: (left: T) => boolean): InputIterator; + /** + *

Copy range removing value.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, except + * those elements that compare equal to val.

+ * + *

The resulting range is shorter than [first, last) by as many elements as matches in the sequence, + * which are "removed".

+ * + *

The function uses {@link equal_to} to compare the individual elements to val.

+ * + * @param first {@link Iterator InputIterator} to the initial position in a sequence. + * @param last {@link Iterator InputIterator} 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. + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element in the range + * [first, last). + * @param val Value to be removed. + * + * @return An iterator pointing to the end of the copied range, which includes all the elements in + * [first, last) except those that compare equal to val. + */ + function remove_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, val: T): OutputIterator; + /** + *

Copy range removing values.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, except + * those elements for which pred returns true.

+ * + *

The resulting range is shorter than [first, last) by as many elements as matches, which are + * "removed".

+ * + * @param first {@link Iterator InputIterator} to the initial position in a sequence. + * @param last {@link Iterator InputIterator} 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. + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element in the range + * [first, last). + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element is to be removed from the copy (if + * true, it is not copied). The function shall not modify its argument. + * + * @return An iterator pointing to the end of the copied range, which includes all the elements in + * [first, last) except those for which pred returns true. + */ + function remove_copy_if, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (val: T) => boolean): OutputIterator; + /** + *

Replace value in range.

+ * + *

Assigns new_val to all the elements in the range [first, last) that compare equal to + * old_val.

+ * + *

The function uses {@link equal_to} to compare the individual elements to old_val.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param old_val Value to be replaced. + * @param new_val Replacement value. + */ + function replace>(first: InputIterator, last: InputIterator, old_val: T, new_val: T): void; + /** + *

Replace value in range.

+ * + *

Assigns new_val to all the elements in the range [first, last) for which pred returns + * true.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element is to be replaced (if + * true, it is replaced). The function shall not modify its argument. + * @param new_val Value to assign to replaced elements. + */ + function replace_if>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean, new_val: T): void; + /** + *

Copy range replacing value.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, replacing + * the appearances of old_value by new_value.

+ * + *

The function uses {@link std.equal_to} to compare the individual elements to old_value.

+ * + *

The ranges shall not overlap in such a way that result points to an element in the range + * [first, last).

+ * + * @param first {@link Iterator InputIterator} to the initial position in a sequence. + * @param last {@link Iterator InputIterator} 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. + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element in the range + * [first, last). + * @param old_val Value to be replaced. + * @param new_val Replacement value. + * + * @return An iterator pointing to the element that follows the last element written in the result sequence. + */ + function replace_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, old_val: T, new_val: T): OutputIterator; + /** + *

Copy range replacing value.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, replacing + * those for which pred returns true by new_value.

+ * + * @param first {@link Iterator InputIterator} to the initial position in a sequence. + * @param last {@link Iterator InputIterator} 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. + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element in the range + * [first, last). + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element is to be removed from the copy (if + * true, it is not copied). The function shall not modify its argument. + * @param new_val Value to assign to replaced values. + * + * @return An iterator pointing to the element that follows the last element written in the result sequence. + */ + function replace_copy_if, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (val: T) => boolean, new_val: T): OutputIterator; + /** + *

Exchange values of objects pointed to by two iterators.

+ * + *

Swaps the elements pointed to by x and y.

+ * + *

The function calls {@link Iterator.swap} to exchange the elements.

+ * + * @param x {@link Iterator Forward iterator} to the objects to swap. + * @param y {@link Iterator Forward iterator} to the objects to swap. + */ + function iter_swap(x: Iterator, y: Iterator): void; + /** + *

Exchange values of two ranges.

+ * + *

Exchanges the values of each of the elements in the range [first1, last1) with those of their + * respective elements in the range beginning at first2.

+ * + *

The function calls {@link Iterator.swap} to exchange the elements.

+ * + * @param first1 {@link Iterator Forward iterator} to the initial position of the first sequence. + * @param last1 {@link Iterator Forward iterator} to the final position of the first sequence. The range used is + * [first1, last1), including the element pointed by first1, but not the element + * pointed by last1. + * @param first2 {@link Iterator Forward iterator} to the initial position of the second range. The range includes as + * many elements as [first1, last1). The two ranges shall not overlap. + * + * @return An iterator to the last element swapped in the second sequence. + */ + function swap_ranges, ForwardIterator2 extends Iterator>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2): ForwardIterator2; + /** + *

Reverse range.

+ * + *

Reverses the order of the elements in the range [first, last).

+ * + *

The function calls {@link iter_swap} to swap the elements to their new locations.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + */ + function reverse>(first: InputIterator, last: InputIterator): void; + /** + *

Copy range reversed.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, but in + * reverse order.

+ * + * @param first {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. + * @param last {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. 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. + * @param result {@link Iterator Output iterator} to the initial position of the range where the reserved range is + * stored. The pointed type shall support being assigned the value of an element in the range + * [first, last). + * + * @return An output iterator pointing to the end of the copied range, which contains the same elements in reverse + * order. + */ + function reverse_copy, OutputIterator extends Iterator>(first: BidirectionalIterator, last: BidirectionalIterator, result: OutputIterator): OutputIterator; + /** + *

Rotate left the elements in range.

+ * + *

Rotates the order of the elements in the range [first, last), in such a way that the element + * pointed by middle becomes the new first element.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param middle An {@link Iterator} pointing to the element within the range [first, last) that is + * moved to the first position in the range. + * @param last An {@link Iterator} 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. + * + * @return An iterator pointing to the element that now contains the value previously pointed by first. + */ + function rotate>(first: InputIterator, middle: InputIterator, last: InputIterator): InputIterator; + /** + *

Copy range rotated left.

+ * + *

Copies the elements in the range [first, last) to the range beginning at result, but + * rotating the order of the elements in such a way that the element pointed by middle becomes the first + * element in the resulting range.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the range to be copy-rotated. + * @param middle Forward iterator pointing to the element within the range [first, last) that is copied as the first element in the resulting range. + * @param last {@link Iterator Forward iterator} to the final positions of the range to be copy-rotated. 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. + * Notice that in this function, these are not consecutive parameters, but the first and third ones. + * @param result {@link Iterator Output iterator} to the initial position of the range where the reserved range is + * stored. The pointed type shall support being assigned the value of an element in the range + * [first, last). + * + * @return An output iterator pointing to the end of the copied range. + */ + function rotate_copy, OutputIterator extends Iterator>(first: ForwardIterator, middle: ForwardIterator, last: ForwardIterator, result: OutputIterator): OutputIterator; + /** + *

Randomly rearrange elements in range.

+ * + *

Rearranges the elements in the range [first, last) randomly.

+ * + *

The function swaps the value of each element with that of some other randomly picked element. When provided, + * the function gen determines which element is picked in every case. Otherwise, the function uses some unspecified + * source of randomness.

+ * + *

To specify a uniform random generator, see {@link shuffle}.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + */ + function random_shuffle>(first: RandomAccessIterator, last: RandomAccessIterator): void; + /** + *

Randomly rearrange elements in range using generator.

+ * + *

Rearranges the elements in the range [first, last) randomly, using g as uniform random + * number generator.

+ * + *

The function swaps the value of each element with that of some other randomly picked element. The function + * determines the element picked by calling g().

+ * + *

To shuffle the elements of the range without such a generator, see {@link random_shuffle} instead.

+ * + *
Note
+ *

Using random generator engine is not implemented yet.

+ * + * @param first An {@link Iterator} to the initial position in a sequence. + * @param last An {@link Iterator} 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. + */ + function shuffle>(first: RandomAccessIterator, last: RandomAccessIterator): void; +} +declare namespace std { + /** + *

Sort elements in range.

+ * + *

Sorts the elements in the range [first, last) into ascending order. The elements are compared + * using {@link less}.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be sorted. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. + * 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which + * {@link Iterator.swap swap} is properly defined. + */ + function sort>(first: RandomAccessIterator, last: RandomAccessIterator): void; + /** + *

Sort elements in range.

+ * + *

Sorts the elements in the range [first, last) into specific order. The elements are compared + * using compare.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be sorted. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. + * 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which + * {@link Iterator.swap swap} is properly defined. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as first + * argument is considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. This can either be a function pointer or a function + * object. + */ + function sort>(first: RandomAccessIterator, last: RandomAccessIterator, compare: (left: T, right: T) => boolean): void; + /** + *

Partially sort elements in range.

+ * + *

Rearranges the elements in the range [first, last), in such a way that the elements before + * middle are the smallest elements in the entire range and are sorted in ascending order, while the remaining + * elements are left without any specific order.

+ * + *

The elements are compared using {@link less}.

+ * + * @param last {@link IArrayIterator Random-access iterator} to the first position of the sequence to be sorted. + * @param middle {@link IArrayIterator Random-access iterator} pointing to the element within the range [first, last) that is used as the upper boundary of the elements that are fully sorted. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. + * 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. + */ + function partial_sort>(first: RandomAccessIterator, middle: RandomAccessIterator, last: RandomAccessIterator): void; + /** + *

Partially sort elements in range.

+ * + *

Rearranges the elements in the range [first, last), in such a way that the elements before + * middle are the smallest elements in the entire range and are sorted in ascending order, while the remaining + * elements are left without any specific order.

+ * + *

The elements are compared using comp.

+ * + * @param last {@link IArrayIterator Random-access iterator} to the first position of the sequence to be sorted. + * @param middle {@link IArrayIterator Random-access iterator} pointing to the element within the range [first, last) that is used as the upper boundary of the elements that are fully sorted. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. + * 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as + * first argument is considered to go before the second in the specific strict weak ordering it + * defines. The function shall not modify any of its arguments. + */ + function partial_sort>(first: RandomAccessIterator, middle: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): void; + /** + *

Copy and partially sort range.

+ * + *

Copies the smallest elements in the range [first, last) to + * [result_first, result_last), sorting the elements copied. The number of elements copied is the same + * as the {@link distance} between result_first and result_last (unless this is more than the amount of + * elements in [first, last)).

+ * + *

The range [first, last) is not modified.

+ * + *

The elements are compared using {@link less}.

+ * + * @param first {@link Iterator Input iterator} to the initial position of the sequence to copy from. + * @param last {@link Iterator Input iterator} to the final position of the sequence to copy from. 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. + * InputIterator shall point to a type assignable to the elements pointed by + * RandomAccessIterator. + * @param result_first {@link Iterator Random-access iterator} to the initial position of the destination sequence. + * @param result_last {@link Iterator Random-access iterator} to the final position of the destination sequence. + * The range used is [result_first, result_last). + * @param compare Binary function that accepts two elements in the result range as arguments, and returns a value + * convertible to bool. The value returned indicates whether the element passed as first + * argument is considered to go before the second in the specific strict weak ordering it + * defines. The function shall not modify any of its arguments. + * + * @return An iterator pointing to the element that follows the last element written in the result sequence. + */ + function partial_sort_copy, RandomAccessIterator extends Iterator>(first: InputIterator, last: InputIterator, result_first: RandomAccessIterator, result_last: RandomAccessIterator): RandomAccessIterator; + /** + *

Copy and partially sort range.

+ * + *

Copies the smallest (or largest) elements in the range [first, last) to + * [result_first, result_last), sorting the elements copied. The number of elements copied is the same + * as the {@link distance} between result_first and result_last (unless this is more than the amount of + * elements in [first, last)).

+ * + *

The range [first, last) is not modified.

+ * + *

The elements are compared using compare.

+ * + * @param first {@link Iterator Input iterator} to the initial position of the sequence to copy from. + * @param last {@link Iterator Input iterator} to the final position of the sequence to copy from. 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. + * InputIterator shall point to a type assignable to the elements pointed by + * RandomAccessIterator. + * @param result_first {@link Iterator Random-access iterator} to the initial position of the destination sequence. + * @param result_last {@link Iterator Random-access iterator} to the final position of the destination sequence. + * The range used is [result_first, result_last). + * @param compare Binary function that accepts two elements in the result range as arguments, and returns a value + * convertible to bool. The value returned indicates whether the element passed as first + * argument is considered to go before the second in the specific strict weak ordering it + * defines. The function shall not modify any of its arguments. + * + * @return An iterator pointing to the element that follows the last element written in the result sequence. + */ + function partial_sort_copy, RandomAccessIterator extends Iterator>(first: InputIterator, last: InputIterator, result_first: RandomAccessIterator, result_last: RandomAccessIterator, compare: (x: T, y: T) => boolean): RandomAccessIterator; + /** + *

Check whether range is sorted.

+ * + *

Returns true if the range [first, last) is sorted into ascending order.

+ * + *

The elements are compared using {@link less}.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the sequence. + * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. + * + * @return true if the range [first, last) is sorted into ascending order, + * false otherwise. If the range [first, last) contains less than two elements, + * the function always returns true. + */ + function is_sorted>(first: ForwardIterator, last: ForwardIterator): boolean; + /** + *

Check whether range is sorted.

+ * + *

Returns true if the range [first, last) is sorted into ascending order.

+ * + *

The elements are compared using compare.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the sequence. + * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible + * to bool. The value returned indicates whether the element passed as first argument is + * considered to go before the second in the specific strict weak ordering it defines. The function + * shall not modify any of its arguments. + * + * @return true if the range [first, last) is sorted into ascending order, + * false otherwise. If the range [first, last) contains less than two elements, + * the function always returns true. + */ + function is_sorted>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): boolean; + /** + *

Find first unsorted element in range.

+ * + *

Returns an iterator to the first element in the range [first, last) which does not follow an + * ascending order.

+ * + *

The range between first and the iterator returned {@link is_sorted is sorted}.

+ * + *

If the entire range is sorted, the function returns last.

+ * + *

The elements are compared using {@link equal_to}.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the sequence. + * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible + * to bool. The value returned indicates whether the element passed as first argument is + * considered to go before the second in the specific strict weak ordering it defines. The function + * shall not modify any of its arguments. + * + * @return An iterator to the first element in the range which does not follow an ascending order, or last if + * all elements are sorted or if the range contains less than two elements. + */ + function is_sorted_until>(first: ForwardIterator, last: ForwardIterator): ForwardIterator; + /** + *

Find first unsorted element in range.

+ * + *

Returns an iterator to the first element in the range [first, last) which does not follow an + * ascending order.

+ * + *

The range between first and the iterator returned {@link is_sorted is sorted}.

+ * + *

If the entire range is sorted, the function returns last.

+ * + *

The elements are compared using compare.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the sequence. + * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible + * to bool. The value returned indicates whether the element passed as first argument is + * considered to go before the second in the specific strict weak ordering it defines. The function + * shall not modify any of its arguments. + * + * @return An iterator to the first element in the range which does not follow an ascending order, or last if + * all elements are sorted or if the range contains less than two elements. + */ + function is_sorted_until>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): ForwardIterator; +} +declare namespace std { + /** + *

Make heap from range.

+ * + *

Rearranges the elements in the range [first, last) in such a way that they form a heap.

+ * + *

A heap is a way to organize the elements of a range that allows for fast retrieval of the element with the + * highest value at any moment (with {@link pop_heap}), even repeatedly, while allowing for fast insertion of new + * elements (with {@link push_heap}).

+ * + *

The element with the highest value is always pointed by first. The order of the other elements depends on the + * particular implementation, but it is consistent throughout all heap-related functions of this header.

+ * + *

The elements are compared using {@link less}: The element with the highest value is an element for which this + * would return false when compared to every other element in the range.

+ * + *

The standard container adaptor {@link PriorityQueue} calls {@link make_heap}, {@link push_heap} and + * {@link pop_heap} automatically to maintain heap properties for a container.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be + * transformed into a heap. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be transformed + * into a heap. 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which + * {@link Iterator.swap swap} is properly defined. + */ + function make_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator): void; + /** + *

Make heap from range.

+ * + *

Rearranges the elements in the range [first, last) in such a way that they form a heap.

+ * + *

A heap is a way to organize the elements of a range that allows for fast retrieval of the element with the + * highest value at any moment (with {@link pop_heap}), even repeatedly, while allowing for fast insertion of new + * elements (with {@link push_heap}).

+ * + *

The element with the highest value is always pointed by first. The order of the other elements depends on the + * particular implementation, but it is consistent throughout all heap-related functions of this header.

+ * + *

The elements are compared using compare: The element with the highest value is an element for which this + * would return false when compared to every other element in the range.

+ * + *

The standard container adaptor {@link PriorityQueue} calls {@link make_heap}, {@link push_heap} and + * {@link pop_heap} automatically to maintain heap properties for a container.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be + * transformed into a heap. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be transformed + * into a heap. 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which + * {@link Iterator.swap swap} is properly defined. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as + * first argument is considered to go before the second in the specific strict weak ordering it defines. + * The function shall not modify any of its arguments. This can either be a function pointer or a + * function object. + */ + function make_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): void; + /** + *

Push element into heap range.

+ * + *

Given a heap in the range [first, last - 1), this function extends the range considered a heap to + * [first, last) by placing the value in (last - 1) into its corresponding location within it. + *

+ * + *

A range can be organized into a heap by calling {@link make_heap}. After that, its heap properties are + * preserved if elements are added and removed from it using {@link push_heap} and {@link pop_heap}, respectively. + *

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the new heap range, including + * the pushed element. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the new heap range, including + * the pushed element. 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which + * {@link Iterator.swap swap} is properly defined. + */ + function push_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator): void; + /** + *

Push element into heap range.

+ * + *

Given a heap in the range [first, last - 1), this function extends the range considered a heap to + * [first, last) by placing the value in (last - 1) into its corresponding location within it. + *

+ * + *

A range can be organized into a heap by calling {@link make_heap}. After that, its heap properties are + * preserved if elements are added and removed from it using {@link push_heap} and {@link pop_heap}, respectively. + *

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the new heap range, including + * the pushed element. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the new heap range, including + * the pushed element. 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which + * {@link Iterator.swap swap} is properly defined. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as + * first argument is considered to go before the second in the specific strict weak ordering it defines. + * The function shall not modify any of its arguments. This can either be a function pointer or a + * function object. + */ + function push_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): void; + /** + *

Pop element from heap range.

+ * + *

Rearranges the elements in the heap range [first, last) in such a way that the part considered a + * heap is shortened by one: The element with the highest value is moved to (last - 1).

+ * + *

While the element with the highest value is moved from first to (last - 1) (which now is out of the + * heap), the other elements are reorganized in such a way that the range [first, last - 1) preserves + * the properties of a heap.

+ * + *

A range can be organized into a heap by calling {@link make_heap}. After that, its heap properties are + * preserved if elements are added and removed from it using {@link push_heap} and {@link pop_heap}, respectively. + *

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the heap to be shrank by one. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the heap to be shrank by one. + * 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + */ + function pop_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator): void; + /** + *

Pop element from heap range.

+ * + *

Rearranges the elements in the heap range [first, last) in such a way that the part considered a + * heap is shortened by one: The element with the highest value is moved to (last - 1).

+ * + *

While the element with the highest value is moved from first to (last - 1) (which now is out of the + * heap), the other elements are reorganized in such a way that the range [first, last - 1) preserves + * the properties of a heap.

+ * + *

A range can be organized into a heap by calling {@link make_heap}. After that, its heap properties are + * preserved if elements are added and removed from it using {@link push_heap} and {@link pop_heap}, respectively. + *

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the heap to be shrank by one. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the heap to be shrank by one. + * 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as + * first argument is considered to go before the second in the specific strict weak ordering it defines. + * The function shall not modify any of its arguments. This can either be a function pointer or a + * function object. + */ + function pop_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): void; + /** + *

Test if range is heap.

+ * + *

Returns true if the range [first, last) forms a heap, as if constructed with {@link make_heap}. + *

+ * + *

The elements are compared using {@link less}.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + * + * @return true if the range [first, last) is a heap (as if constructed with + * {@link make_heap}), false otherwise. If the range [first, last) contains less + * than two elements, the function always returns true. + */ + function is_heap>(first: RandomAccessIterator, last: RandomAccessIterator): boolean; + /** + *

Test if range is heap.

+ * + *

Returns true if the range [first, last) forms a heap, as if constructed with {@link make_heap}. + *

+ * + *

The elements are compared using compare.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as + * first argument is considered to go before the second in the specific strict weak ordering it defines. + * The function shall not modify any of its arguments. This can either be a function pointer or a + * function object. + * + * @return true if the range [first, last) is a heap (as if constructed with + * {@link make_heap}), false otherwise. If the range [first, last) contains less + * than two elements, the function always returns true. + */ + function is_heap>(first: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): boolean; + /** + *

Find first element not in heap order.

+ * + *

Returns an iterator to the first element in the range [first, last) which is not in a valid + * position if the range is considered a heap (as if constructed with {@link make_heap}).

+ * + *

The range between first and the iterator returned is a heap.

+ * + *

If the entire range is a valid heap, the function returns last.

+ * + *

The elements are compared using {@link less}.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + */ + function is_heap_until>(first: RandomAccessIterator, last: RandomAccessIterator): RandomAccessIterator; + /** + *

Find first element not in heap order.

+ * + *

Returns an iterator to the first element in the range [first, last) which is not in a valid + * position if the range is considered a heap (as if constructed with {@link make_heap}).

+ * + *

The range between first and the iterator returned is a heap.

+ * + *

If the entire range is a valid heap, the function returns last.

+ * + *

The elements are compared using {@link less}.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as + * first argument is considered to go before the second in the specific strict weak ordering it defines. + * The function shall not modify any of its arguments. This can either be a function pointer or a + * function object. + */ + function is_heap_until>(first: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): RandomAccessIterator; + /** + *

Sort elements of heap.

+ * + *

Sorts the elements in the heap range [first, last) into ascending order.

+ * + *

The elements are compared using {@link less}, which shall be the same as used to construct the heap.

+ * + *

The range loses its properties as a heap.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be sorted. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. + * 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + */ + function sort_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator): void; + /** + *

Sort elements of heap.

+ * + *

Sorts the elements in the heap range [first, last) into ascending order.

+ * + *

The elements are compared using compare, which shall be the same as used to construct the heap.

+ * + *

The range loses its properties as a heap.

+ * + * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be sorted. + * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. + * 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. + * {@link IArrayIterator RandomAccessIterator} shall point to a type for which {@link Iterator.swap swap} + * is properly defined. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value + * convertible to boolean. The value returned indicates whether the element passed as + * first argument is considered to go before the second in the specific strict weak ordering it defines. + * The function shall not modify any of its arguments. This can either be a function pointer or a + * function object. + */ + function sort_heap>(fisrt: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): void; +} +declare namespace std { + /** + *

Return iterator to lower bound.

+ * + *

Returns an iterator pointing to the first element in the range [first, last) which does not + * compare less than val.

+ * + *

The elements are compared using {@link less}. The elements in the range shall already be {@link is_sorted sorted} + * according to this same criterion ({@link less}), or at least {@link is_partitioned partitioned} with respect to + * val.

+ * + *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted + * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

+ * + *

Unlike {@link upper_bound}, the value pointed by the iterator returned by this function may also be equivalent + * to val, and not only greater.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared + * with elements of the range [first, last) as the left-hand side operand of {@link less}. + * + * @return An iterator to the lower bound of val in the range. If all the element in the range compare less than + * val, the function returns last. + */ + function lower_bound>(first: ForwardIterator, last: ForwardIterator, val: T): ForwardIterator; + /** + *

Return iterator to lower bound.

+ * + *

Returns an iterator pointing to the first element in the range [first, last) which does not + * compare less than val.

+ * + *

The elements are compared using compare. The elements in the range shall already be + * {@link is_sorted sorted} according to this same criterion (compare), or at least + * {@link is_partitioned partitioned} with respect to val.

+ * + *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted + * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

+ * + *

Unlike {@link upper_bound}, the value pointed by the iterator returned by this function may also be equivalent + * to val, and not only greater.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. + * @param compare Binary function that accepts two arguments (the first of the type pointed by ForwardIterator, + * and the second, always val), and returns a value convertible to bool. The value + * returned indicates whether the first argument is considered to go before the second. The function + * shall not modify any of its arguments. + * + * @return An iterator to the lower bound of val in the range. If all the element in the range compare less than + * val, the function returns last. + */ + function lower_bound>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): ForwardIterator; + /** + *

Return iterator to upper bound.

+ * + *

Returns an iterator pointing to the first element in the range [first, last) which compares + * greater than val.

+ * + *

The elements are compared using {@link less}. The elements in the range shall already be {@link is_sorted sorted} + * according to this same criterion ({@link less}), or at least {@link is_partitioned partitioned} with respect to + * val.

+ * + *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted + * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

+ * + *

Unlike {@link lower_bound}, the value pointed by the iterator returned by this function cannot be equivalent to + * val, only greater.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared + * with elements of the range [first, last) as the left-hand side operand of {@link less}. + * + * @return An iterator to the upper bound of val in the range. If no element in the range comparse greater than + * val, the function returns last. + */ + function upper_bound>(first: ForwardIterator, last: ForwardIterator, val: T): ForwardIterator; + /** + *

Return iterator to upper bound.

+ * + *

Returns an iterator pointing to the first element in the range [first, last) which compares + * greater than val.

+ * + *

The elements are compared using compare. The elements in the range shall already be + * {@link is_sorted sorted} according to this same criterion (compare), or at least + * {@link is_partitioned partitioned} with respect to val.

+ * + *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted + * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

+ * + *

Unlike {@link lower_bound}, the value pointed by the iterator returned by this function cannot be equivalent to + * val, only greater.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. + * @param compare Binary function that accepts two arguments (the first of the type pointed by ForwardIterator, + * and the second, always val), and returns a value convertible to bool. The value + * returned indicates whether the first argument is considered to go before the second. The function + * shall not modify any of its arguments. + * + * @return An iterator to the upper bound of val in the range. If no element in the range comparse greater than + * val, the function returns last. + */ + function upper_bound>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): ForwardIterator; + /** + *

Get subrange of equal elements.

+ * + *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with + * values equivalent to val.

+ * + *

The elements are compared using {@link less}. Two elements, ax/i> and y are considered equivalent + * if (!std.less(x, y) && !std.less(y, x)).

+ * + *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion + * ({@link less}), or at least {@link is_partitioned partitioned} with respect to val.

+ * + *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both + * iterators pointing to the nearest value greater than val, if any, or to last, if val compares + * greater than all the elements in the range.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared + * with elements of the range [first, last) as the left-hand side operand of {@link less}. + * + * @return A {@link Pair} object, whose member {@link Pair.first} is an iterator to the lower bound of the subrange of + * equivalent values, and {@link Pair.second} its upper bound. The values are the same as those that would be + * returned by functions {@link lower_bound} and {@link upper_bound} respectively. + */ + function equal_range>(first: ForwardIterator, last: ForwardIterator, val: T): Pair; + /** + *

Get subrange of equal elements.

+ * + *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with + * values equivalent to val.

+ * + *

The elements are compared using compare. Two elements, ax/i> and y are considered equivalent + * if (!compare(x, y) && !compare(y, x)).

+ * + *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion + * (compare), or at least {@link is_partitioned partitioned} with respect to val.

+ * + *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both + * iterators pointing to the nearest value greater than val, if any, or to last, if val compares + * greater than all the elements in the range.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. + * @param compare Binary function that accepts two arguments of the type pointed by ForwardIterator (and of type + * T), and returns a value convertible to bool. The value returned indicates whether + * the first argument is considered to go before the second. The function shall not modify any of its + * arguments. + * + * @return A {@link Pair} object, whose member {@link Pair.first} is an iterator to the lower bound of the subrange of + * equivalent values, and {@link Pair.second} its upper bound. The values are the same as those that would be + * returned by functions {@link lower_bound} and {@link upper_bound} respectively. + */ + function equal_range>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): Pair; + /** + *

Get subrange of equal elements.

+ * + *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with + * values equivalent to val.

+ * + *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent + * if (!std.less(x, y) && !std.less(y, x)).

+ * + *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion + * ({@link less}), or at least {@link is_partitioned partitioned} with respect to val.

+ * + *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both + * iterators pointing to the nearest value greater than val, if any, or to last, if val compares + * greater than all the elements in the range.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared + * with elements of the range [first, last) as the left-hand side operand of {@link less}. + * + * @return true if an element equivalent to val is found, and false otherwise. + */ + function binary_search>(first: ForwardIterator, last: ForwardIterator, val: T): boolean; + /** + *

Get subrange of equal elements.

+ * + *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with + * values equivalent to val.

+ * + *

The elements are compared using {compare}. Two elements, x and y are considered equivalent + * if (!compare(x, y) && !compare(y, x)).

+ * + *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion + * (compare), or at least {@link is_partitioned partitioned} with respect to val.

+ * + *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both + * iterators pointing to the nearest value greater than val, if any, or to last, if val compares + * greater than all the elements in the range.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) sequence. + * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly + * {@link is_partitioned partitioned}) 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. + * @param val Value of the lower bound to search for in the range. + * @param compare Binary function that accepts two arguments of the type pointed by ForwardIterator (and of type + * T), and returns a value convertible to bool. The value returned indicates whether + * the first argument is considered to go before the second. The function shall not modify any of its + * arguments. + * + * @return true if an element equivalent to val is found, and false otherwise. + */ + function binary_search>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): boolean; +} +declare namespace std { + /** + *

Test whether range is partitioned.

+ * + *

Returns true if all the elements in the range [first, last) for which pred + * returns true precede those for which it returns false.

+ * + *

If the range is {@link IContainer.empty empty}, the function returns true.

+ * + * @param first {@link Iterator Input iterator} to the initial position of the sequence. + * @param last {@link Iterator Input iterator} to the final position of the 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. + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element belongs to the first group (if + * true, the element is expected before all the elements for which it returns + * false). The function shall not modify its argument. + * + * @return true if all the elements in the range [first, last) for which pred returns + * true precede those for which it returns false. Otherwise it returns + * false. If the range is {@link IContainer.empty empty}, the function returns true. + */ + function is_partitioned>(first: InputIterator, last: InputIterator, pred: (x: T) => boolean): boolean; + /** + *

Partition range in two.

+ * + *

Rearranges the elements from the range [first, last), in such a way that all the elements for + * which pred returns true precede all those for which it returns false. The iterator + * returned points to the first element of the second group.

+ * + *

The relative ordering within each group is not necessarily the same as before the call. See + * {@link stable_partition} for a function with a similar behavior but with stable ordering within each group.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the sequence to partition. + * @param last {@link Iterator Forward iterator} to the final position of the sequence to partition. 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. + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element belongs to the first group (if + * true, the element is expected before all the elements for which it returns + * false). The function shall not modify its argument. + * + * @return An iterator that points to the first element of the second group of elements (those for which pred + * returns false), or last if this group is {@link IContainer.empty empty}. + */ + function partition>(first: BidirectionalIterator, last: BidirectionalIterator, pred: (x: T) => boolean): BidirectionalIterator; + /** + *

Partition range in two - stable ordering.

+ * + *

Rearranges the elements in the range [first, last), in such a way that all the elements for which + * pred returns true precede all those for which it returns false, and, unlike + * function {@link partition}, the relative order of elements within each group is preserved.

+ * + *

This is generally implemented using an internal temporary buffer.

+ * + * @param first {@link Iterator Bidirectional iterator} to the initial position of the sequence to partition. + * @param last {@link Iterator Bidirectional iterator} to the final position of the sequence to partition. 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. + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element belongs to the first group (if + * true, the element is expected before all the elements for which it returns + * false). The function shall not modify its argument. + * + * @return An iterator that points to the first element of the second group of elements (those for which pred + * returns false), or last if this group is {@link IContainer.empty empty}. + */ + function stable_partition>(first: BidirectionalIterator, last: BidirectionalIterator, pred: (x: T) => boolean): BidirectionalIterator; + /** + *

Partition range into two.

+ * + *

Copies the elements in the range [first, last) for which pred returns true + * into the range pointed by result_true, and those for which it does not into the range pointed by + * result_false.

+ * + * @param first {@link Iterator Input iterator} to the initial position of the range to be copy-partitioned. + * @param last {@link Iterator Input iterator} to the final position of the range to be copy-partitioned. 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. + * @param result_true {@link Iterator Output iterator} to the initial position of the range where the elements for + * which pred returns true are stored. + * @param result_false {@link Iterator Output iterator} to the initial position of the range where the elements for + * which pred returns false are stored. + * @param pred Unary function that accepts an element pointed by InputIterator as argument, and returns a value + * convertible to bool. The value returned indicates on which result range the element is + * copied. The function shall not modify its argument. + * + * @return A {@link Pair} of iterators with the end of the generated sequences pointed by result_true and + * result_false, respectivelly. Its member {@link Pair.first first} points to the element that follows + * the last element copied to the sequence of elements for which pred returned true. Its + * member {@link Pair.second second} points to the element that follows the last element copied to the sequence + * of elements for which pred returned false. + */ + function partition_copy, OutputIterator1 extends Iterator, OutputIterator2 extends Iterator>(first: InputIterator, last: InputIterator, result_true: OutputIterator1, result_false: OutputIterator2, pred: (val: T) => T): Pair; + /** + *

Get partition point.

+ * + *

Returns an iterator to the first element in the partitioned range [first, last) for which + * pred is not true, indicating its partition point.

+ * + *

The elements in the range shall already {@link is_partitioned be partitioned}, as if {@link partition} had been + * called with the same arguments.

+ * + *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted + * range, which is specially efficient for {@link Iteartor random-access iterators}.

+ * + * @param first {@link Iterator Forward iterator} to the initial position of the partitioned sequence. + * @param last {@link Iterator Forward iterator} to the final position of the partitioned sequence. The range checked + * is [first, last), which contains all the elements between first an last, + * including the element pointed by first but not the element pointed by last. + * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to + * bool. The value returned indicates whether the element goes before the partition point (if + * true, it goes before; if false goes at or after it). The function shall not + * modify its argument. + * + * @return An iterator to the first element in the partitioned range [first, last) for which pred + * is not true, or last if it is not true for any element. + */ + function partition_point>(first: ForwardIterator, last: ForwardIterator, pred: (x: T) => boolean): ForwardIterator; +} +declare namespace std { + /** + *

Merge sorted ranges.

+ * + *

Combines the elements in the sorted ranges [first1, last1) and [first2, last2), into + * a new range beginning at result with all its elements sorted.

+ * + *

The elements are compared using {@link less}. The elements in both ranges shall already be ordered according to + * this same criterion ({@link less}). The resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting combined + * range is stored. Its size is equal to the sum of both ranges above. + * + * @return An iterator pointing to the past-the-end element in the resulting sequence. + */ + function merge, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; + /** + *

Merge sorted ranges.

+ * + *

Combines the elements in the sorted ranges [first1, last1) and [first2, last2), into + * a new range beginning at result with all its elements sorted.

+ * + *

The elements are compared using {@link less}. The elements in both ranges shall already be ordered according to + * this same criterion (compare). The resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting combined + * range is stored. Its size is equal to the sum of both ranges above. + * @param compare Binary function that accepts two arguments of the types pointed by the iterators, and returns a value + * convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. + * + * @return An iterator pointing to the past-the-end element in the resulting sequence. + */ + function merge, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; + /** + *

Merge consecutive sorted ranges.

+ * + *

Merges two consecutive sorted ranges: [first, middle) and [middle, last), putting + * the result into the combined sorted range [first, last).

+ * + *

The elements are compared using {@link less}. The elements in both ranges shall already be ordered according to + * this same criterion ({@link less}). The resulting range is also sorted according to this.

+ * + *

The function preserves the relative order of elements with equivalent values, with the elements in the first + * range preceding those equivalent in the second.

+ * + * @param first {@link Iterator Bidirectional iterator} to the initial position in the first sorted sequence to merge. + * This is also the initial position where the resulting merged range is stored. + * @param middle {@link Iterator Bidirectional iterator} to the initial position of the second sorted sequence, which + * because both sequences must be consecutive, matches the past-the-end position of the first + * sequence. + * @param last {@link Iterator Bidirectional iterator} to the past-the-end position of the second sorted + * sequence. This is also the past-the-end position of the range where the resulting merged range is + * stored. + */ + function inplace_merge>(first: BidirectionalIterator, middle: BidirectionalIterator, last: BidirectionalIterator): void; + /** + *

Merge consecutive sorted ranges.

+ * + *

Merges two consecutive sorted ranges: [first, middle) and [middle, last), putting + * the result into the combined sorted range [first, last).

+ * + *

The elements are compared using compare. The elements in both ranges shall already be ordered according + * to this same criterion (compare). The resulting range is also sorted according to this.

+ * + *

The function preserves the relative order of elements with equivalent values, with the elements in the first + * range preceding those equivalent in the second.

+ * + * @param first {@link Iterator Bidirectional iterator} to the initial position in the first sorted sequence to merge. + * This is also the initial position where the resulting merged range is stored. + * @param middle {@link Iterator Bidirectional iterator} to the initial position of the second sorted sequence, which + * because both sequences must be consecutive, matches the past-the-end position of the first + * sequence. + * @param last {@link Iterator Bidirectional iterator} to the past-the-end position of the second sorted + * sequence. This is also the past-the-end position of the range where the resulting merged range is + * stored. + * @param compare Binary function that accepts two arguments of the types pointed by the iterators, and returns a value + * convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. + */ + function inplace_merge>(first: BidirectionalIterator, middle: BidirectionalIterator, last: BidirectionalIterator, compare: (x: T, y: T) => boolean): void; + /** + *

Test whether sorted range includes another sorted range.

+ * + *

Returns true if the sorted range [first1, last1) contains all the elements in the + * sorted range [first2, last2).

+ * + *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent + * if (!std.less(x, y) && !std.less(y, x)).

+ * + *

The elements in the range shall already be ordered according to this same criterion ({@link less}).

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence (which is tested on + * whether it contains the second sequence). The range used is [first1, last1), which + * contains all the elements between first1 and last1, including the element pointed by + * first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. (which is tested + * on whether it is contained in the first sequence). The range used is [first2, last2). + * + * @return true if every element in the range [first2, last2) is contained in the range + * [first1, last1), false otherwise. If [first2, last2) is an empty + * range, the function returns true. + */ + function includes, InputIterator2 extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2): boolean; + /** + *

Test whether sorted range includes another sorted range.

+ * + *

Returns true if the sorted range [first1, last1) contains all the elements in the + * sorted range [first2, last2).

+ * + *

The elements are compared using compare. Two elements, x and y are considered equivalent + * if (!compare(x, y) && !compare(y, x)).

+ * + *

The elements in the range shall already be ordered according to this same criterion (compare).

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence (which is tested on + * whether it contains the second sequence). The range used is [first1, last1), which + * contains all the elements between first1 and last1, including the element pointed by + * first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. (which is tested + * on whether it is contained in the first sequence). The range used is [first2, last2). + * @param compare Binary function that accepts two elements as arguments (one from each of the two sequences, in the + * same order), and returns a value convertible to bool. The value returned indicates + * whether the element passed as first argument is considered to go before the second in the specific + * strict weak ordering it defines. The function shall not modify any of its arguments. + * + * @return true if every element in the range [first2, last2) is contained in the range + * [first1, last1), false otherwise. If [first2, last2) is an empty + * range, the function returns true. + */ + function includes, InputIterator2 extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, compare: (x: T, y: T) => boolean): boolean; + /** + *

Union of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by result with the set union of the + * two sorted ranges [first1, last1) and [first2, last2).

+ * + *

The union of two sets is formed by the elements that are present in either one of the sets, or in both. + * Elements from the second range that have an equivalent element in the first range are not copied to the resulting + * range.

+ * + *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent + * if (!std.less(x, y) && !std.less(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion ({@link less}). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the other ranges. + * + * @return An iterator to the end of the constructed range. + */ + function set_union, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; + /** + *

Union of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by result with the set union of the + * two sorted ranges [first1, last1) and [first2, last2).

+ * + *

The union of two sets is formed by the elements that are present in either one of the sets, or in both. + * Elements from the second range that have an equivalent element in the first range are not copied to the resulting + * range.

+ * + *

The elements are compared using compare. Two elements, x and y are considered equivalent + * if (!compare(x, y) && !compare(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion (compare). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the other ranges. + * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a + * value convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. + * + * @return An iterator to the end of the constructed range. + */ + function set_union, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; + /** + *

Intersection of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by result with the set intersection of + * the two sorted ranges [first1, last1) and [first2, last2).

+ * + *

The intersection of two sets is formed only by the elements that are present in both sets. The elements + * copied by the function come always from the first range, in the same order.

+ * + *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent + * if (!std.less(x, y) && !std.less(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion ({@link less}). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the first range. + * + * @return An iterator to the end of the constructed range. + */ + function set_intersection, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; + /** + *

Intersection of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by result with the set intersection of + * the two sorted ranges [first1, last1) and [first2, last2).

+ * + *

The intersection of two sets is formed only by the elements that are present in both sets. The elements + * copied by the function come always from the first range, in the same order.

+ * + *

The elements are compared using compare. Two elements, x and y are considered equivalent + * if (!compare(x, y) && !compare(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion (compare). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the first range. + * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a + * value convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. + * + * @return An iterator to the end of the constructed range. + */ + function set_intersection, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; + /** + *

Difference of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by result with the set difference of + * the sorted range [first1, last1) with respect to the sorted range [first2, last2).

+ * + *

The difference of two sets is formed by the elements that are present in the first set, but not in the + * second one. The elements copied by the function come always from the first range, in the same order.

+ * + *

For containers supporting multiple occurrences of a value, the difference includes as many occurrences of + * a given value as in the first range, minus the amount of matching elements in the second, preserving order.

+ * + *

Notice that this is a directional operation - for a symmetrical equivalent, see {@link set_symmetric_difference}. + *

+ * + *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent + * if (!std.less(x, y) && !std.less(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion ({@link less}). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the first range. + * + * @return An iterator to the end of the constructed range. + */ + function set_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; + /** + *

Difference of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by result with the set difference of + * the sorted range [first1, last1) with respect to the sorted range [first2, last2).

+ * + *

The difference of two sets is formed by the elements that are present in the first set, but not in the + * second one. The elements copied by the function come always from the first range, in the same order.

+ * + *

For containers supporting multiple occurrences of a value, the difference includes as many occurrences of + * a given value as in the first range, minus the amount of matching elements in the second, preserving order.

+ * + *

Notice that this is a directional operation - for a symmetrical equivalent, see {@link set_symmetric_difference}. + *

+ * + *

The elements are compared using compare. Two elements, x and y are considered equivalent + * if (!compare(x, y) && !compare(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion (compare). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the first range. + * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a + * value convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. + * + * @return An iterator to the end of the constructed range. + */ + function set_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; + /** + *

Symmetric difference of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by0 result with the set + * symmetric difference of the two sorted ranges [first1, last1) and [first2, last2). + *

+ * + *

The symmetric difference of two sets is formed by the elements that are present in one of the sets, but + * not in the other. Among the equivalent elements in each range, those discarded are those that appear before in the + * existent order before the call. The existing order is also preserved for the copied elements.

+ * + *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent + * if (!std.less(x, y) && !std.less(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion ({@link std.less}). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the other ranges. + * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a + * value convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. + * + * @return An iterator to the end of the constructed range. + */ + function set_symmetric_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; + /** + *

Symmetric difference of two sorted ranges.

+ * + *

Constructs a sorted range beginning in the location pointed by0 result with the set + * symmetric difference of the two sorted ranges [first1, last1) and [first2, last2). + *

+ * + *

The symmetric difference of two sets is formed by the elements that are present in one of the sets, but + * not in the other. Among the equivalent elements in each range, those discarded are those that appear before in the + * existent order before the call. The existing order is also preserved for the copied elements.

+ * + *

The elements are compared using compare. Two elements, x and y are considered equivalent + * if (!compare(x, y) && !compare(y, x)).

+ * + *

The elements in the ranges shall already be ordered according to this same criterion (compare). The + * resulting range is also sorted according to this.

+ * + * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. + * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is + * [first1, last1), which contains all the elements between first1 and last1, + * including the element pointed by first1 but not the element pointed by last1. + * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. + * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is + * [first2, last2). + * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is + * stored. The pointed type shall support being assigned the value of an element from the other ranges. + * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a + * value convertible to bool. The value returned indicates whether the first argument is + * considered to go before the second in the specific strict weak ordering it defines. The + * function shall not modify any of its arguments. + * + * @return An iterator to the end of the constructed range. + */ + function set_symmetric_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; +} +declare namespace std { + /** + *

Return the smallest.

+ * + *

Returns the smallest of all the elements in the args.

+ * + * @param args Values to compare. + * + * @return The lesser of the values passed as arguments. + */ + function min(...args: T[]): T; + /** + *

Return the largest.

+ * + *

Returns the largest of all the elements in the args.

+ * + * @param args Values to compare. + * + * @return The largest of the values passed as arguments. + */ + function max(...args: T[]): T; + /** + *

Return smallest and largest elements.

+ * + *

Returns a {@link Pair} with the smallest of all the elements in the args as first element (the first of + * them, if there are more than one), and the largest as second (the last of them, if there are more than one).

+ * + * @param args Values to compare. + * + * @return The lesser and greatest of the values passed as arguments. + */ + function minmax(...args: T[]): Pair; + /** + *

Return smallest element in range.

+ * + *

Returns an iterator pointing to the element with the smallest value in the range [first, last). + *

+ * + *

The comparisons are performed using either {@link less}; An element is the smallest if no other element + * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first + * of such elements.

+ * + * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. + * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. + * + * @return An iterator to smallest value in the range, or last if the range is empty. + */ + function min_element>(first: ForwardIterator, last: ForwardIterator): ForwardIterator; + /** + *

Return smallest element in range.

+ * + *

Returns an iterator pointing to the element with the smallest value in the range [first, last). + *

+ * + *

The comparisons are performed using either compare; An element is the smallest if no other element + * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first + * of such elements.

+ * + * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. + * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible + * to bool. The value returned indicates whether the element passed as first argument is + * considered less than the second. The function shall not modify any of its arguments. + * + * @return An iterator to smallest value in the range, or last if the range is empty. + */ + function min_element>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): ForwardIterator; + /** + *

Return largest element in range.

+ * + *

Returns an iterator pointing to the element with the largest value in the range [first, last). + *

+ * + *

The comparisons are performed using either {@link greater}; An element is the largest if no other element + * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first + * of such elements.

+ * + * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. + * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. + * + * @return An iterator to largest value in the range, or last if the range is empty. + */ + function max_element>(first: ForwardIterator, last: ForwardIterator): ForwardIterator; + /** + *

Return largest element in range.

+ * + *

Returns an iterator pointing to the element with the largest value in the range [first, last). + *

+ * + *

The comparisons are performed using either compare; An element is the largest if no other element + * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first + * of such elements.

+ * + * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. + * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible + * to bool. The value returned indicates whether the element passed as first argument is + * considered less than the second. The function shall not modify any of its arguments. + * + * @return An iterator to largest value in the range, or last if the range is empty. + */ + function max_element>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): ForwardIterator; + /** + *

Return smallest and largest elements in range.

+ * + *

Returns a {@link Pair} with an iterator pointing to the element with the smallest value in the range + * [first, last) as first element, and the largest as second.

+ * + *

The comparisons are performed using either {@link less} and {@link greater}.

+ * + *

If more than one equivalent element has the smallest value, the first iterator points to the first of such + * elements.

+ * + *

If more than one equivalent element has the largest value, the second iterator points to the last of such + * elements.

+ * + * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. + * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible + * to bool. The value returned indicates whether the element passed as first argument is + * considered less than the second. The function shall not modify any of its arguments. + * + * @return A {@link Pair} with an iterator pointing to the element with the smallest value in the range + * [first, last) as first element, and the largest as second. + */ + function minmax_element>(first: ForwardIterator, last: ForwardIterator): Pair; + /** + *

Return smallest and largest elements in range.

+ * + *

Returns a {@link Pair} with an iterator pointing to the element with the smallest value in the range + * [first, last) as first element, and the largest as second.

+ * + *

The comparisons are performed using either compare.

+ * + *

If more than one equivalent element has the smallest value, the first iterator points to the first of such + * elements.

+ * + *

If more than one equivalent element has the largest value, the second iterator points to the last of such + * elements.

+ * + * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. + * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. + * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible + * to bool. The value returned indicates whether the element passed as first argument is + * considered less than the second. The function shall not modify any of its arguments. + * + * @return A {@link Pair} with an iterator pointing to the element with the smallest value in the range + * [first, last) as first element, and the largest as second. + */ + function minmax_element>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): Pair; +} +declare namespace std.base { + /** + *

An abstract container.

+ * + *

+ * + *

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 elements. + * + * @author Jeongho Nam + */ + abstract class Container implements IContainer { + /** + *

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(array: Array); + /** + *

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: IContainer); + /** + *

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 + */ + abstract assign>(begin: InputIterator, end: InputIterator): void; + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + abstract begin(): Iterator; + /** + * @inheritdoc + */ + abstract end(): Iterator; + /** + * @inheritdoc + */ + abstract rbegin(): base.IReverseIterator; + /** + * @inheritdoc + */ + abstract rend(): base.IReverseIterator; + /** + * @inheritdoc + */ + abstract size(): number; + /** + * @inheritdoc + */ + empty(): boolean; + /** + * @inheritdoc + */ + abstract push(...items: U[]): number; + /** + * @inheritdoc + */ + abstract insert(position: Iterator, val: T): Iterator; + /** + * @inheritdoc + */ + abstract erase(position: Iterator): Iterator; + /** + * @inheritdoc + */ + abstract erase(begin: Iterator, end: Iterator): Iterator; + /** + * @inheritdoc + */ + swap(obj: IContainer): void; + } +} declare namespace std { /** *

Bi-directional iterator.

@@ -118,6 +2987,8 @@ declare namespace std { 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. *

@@ -334,625 +3205,6 @@ declare namespace std { */ function end(container: base.MapContainer): MapIterator; } -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.IArrayContainer { - /** - * Type definition of {@link Vector}'s {@link VectorIterator iterator}. - */ - static iterator: typeof VectorIterator; - /** - *

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: base.IContainer); - /** - *

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; - /** - * @hiddde - */ - protected erase_by_range(first: VectorIterator, last: VectorIterator): VectorIterator; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - } - /** - *

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. - */ - 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; - } - /** - *

A reverse-iterator of Vector.

- * - *

- * - * @param Type of the elements. - * - * @author Jeongho Nam - */ - class VectorReverseIterator extends ReverseIterator, VectorReverseIterator> implements base.IArrayIterator { - constructor(base: VectorIterator); - /** - * @inheritdoc - */ - protected create_neighbor(): VectorReverseIterator; - /** - * Set value. - */ - value: T; - /** - * Get index. - */ - index: number; - } -} -declare namespace std.base { - /** - *

An abstract container.

- * - *

- * - *

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 elements. - * - * @author Jeongho Nam - */ - abstract class Container implements IContainer { - /** - *

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(array: Array); - /** - *

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: IContainer); - /** - *

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 - */ - abstract assign>(begin: InputIterator, end: InputIterator): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - abstract begin(): Iterator; - /** - * @inheritdoc - */ - abstract end(): Iterator; - /** - * @inheritdoc - */ - abstract rbegin(): base.IReverseIterator; - /** - * @inheritdoc - */ - abstract rend(): base.IReverseIterator; - /** - * @inheritdoc - */ - abstract size(): number; - /** - * @inheritdoc - */ - empty(): boolean; - /** - * @inheritdoc - */ - abstract push(...items: U[]): number; - /** - * @inheritdoc - */ - abstract insert(position: Iterator, val: T): Iterator; - /** - * @inheritdoc - */ - abstract erase(position: Iterator): Iterator; - /** - * @inheritdoc - */ - abstract erase(begin: Iterator, end: Iterator): Iterator; - /** - * @inheritdoc - */ - swap(obj: IContainer): void; - } -} declare namespace std { /** *

Double ended queue.

@@ -1266,6 +3518,8 @@ declare namespace std { */ private swap_deque(obj); } +} +declare namespace std { /** *

An iterator of {@link Deque}.

* @@ -1334,6 +3588,8 @@ declare namespace std { */ swap(obj: DequeIterator): void; } +} +declare namespace std { /** *

A reverse-iterator of Deque.

* @@ -1361,1824 +3617,820 @@ declare namespace std { } declare namespace std { /** - *

Doubly linked list.

+ *

Function handling termination on exception

* - *

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

+ *

Calls the current terminate handler.

* - *

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.

+ *

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

* - *

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.

+ *

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.

* - *

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.

+ *

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.

* - *

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).

+ *

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.

* - *

Container properties

- *
- *
Sequence
- *
Elements in sequence containers are ordered in a strict linear sequence. Individual elements are accessed by - * their position in this sequence.
+ *

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

* - *
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 f Function that takes no parameters and returns no value (void). + */ + function set_terminate(f: () => void): void; + /** + *

Get terminate handler function.

* - * @param Type of the elements. + *

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.

* - * @reference http://www.cplusplus.com/reference/list/list/ + *

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 List extends base.Container implements base.IDequeContainer { + class Exception extends Error { /** - * An iterator of beginning. + * A message representing specification about the Exception. */ - protected begin_: ListIterator; + private description; /** - * An iterator of end. - */ - protected end_: ListIterator; - /** - * Number of elements in the {@link List}. - */ - protected size_: number; - /** - *

Default Constructor.

- * - *

Constructs an empty container, with no elements.

+ * Default Constructor. */ constructor(); /** - *

Initializer list Constructor.

+ *

Construct from a message.

* - *

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. + * @param message A message representing specification about the Exception. */ - constructor(items: Array); + constructor(message: string); /** - *

Fill Constructor.

+ *

Get string identifying exception.

+ *

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

* - *

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. + *

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.

*/ - 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: base.IContainer); - /** - *

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); + what(): string; /** * @inheritdoc */ - assign(n: number, val: T): void; + message: string; /** * @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; - /** - * @inheritdoc - */ - swap(obj: base.IContainer): void; - /** - * @hidden - */ - private swap_list(obj); + name: string; } /** - *

An iterator, node of a List.

+ *

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 ListIterator extends Iterator { - private prev_; - private next_; - private value_; + class LogicError extends Exception { /** - *

Construct from the source {@link List container}.

+ *

Construct from a message.

* - *

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). + * @param message A message representing specification about the Exception. */ - constructor(source: List, prev: ListIterator, next: ListIterator, value: T); - /** - * @inheritdoc - */ - set_prev(it: ListIterator): void; - /** - * @inheritdoc - */ - set_next(next: ListIterator): void; - private list(); - /** - * @inheritdoc - */ - prev(): ListIterator; - /** - * @inheritdoc - */ - next(): ListIterator; - /** - * @inheritdoc - */ - advance(step: number): ListIterator; - /** - * @inheritdoc - */ - value: T; - /** - * @inheritdoc - */ - equal_to(obj: ListIterator): boolean; - /** - * @inheritdoc - */ - swap(obj: ListIterator): void; + constructor(message: string); } /** - *

A reverse-iterator of List.

+ *

Domain error exception.

* - *

+ *

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

* - * @param Type of the elements. + *

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 ListReverseIterator extends ReverseIterator, ListReverseIterator> { - constructor(base: ListIterator); + class DomainError extends LogicError { /** - * @inheritdoc + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. */ - protected create_neighbor(): ListReverseIterator; + 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 { /** - * @inheritdoc + *

Construct from a message.

+ * + * @param message A message representing specification about the Exception. */ - value: T; + 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/outflow_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 { /** - *

FIFO queue.

+ *

Function object class for equality comparison.

* - *

{@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. - *

+ *

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

* - *

{@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()}.

+ *

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.

* - *

{@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:

+ * @param x First element to compare. + * @param y Second element to compare. * - *
    - *
  • empty
  • - *
  • size
  • - *
  • front
  • - *
  • back
  • - *
  • push_back
  • - *
  • pop_front
  • - *
+ * @return Whether the arguments are equal. + */ + function equal_to(x: T, y: T): boolean; + /** + *

Function object class for non-equality comparison.

* - *

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.

+ *

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 Type of elements. + * @param x First element to compare. + * @param y Second element to compare. * - * @reference http://www.cplusplus.com/reference/queue/queue + * @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 */ - 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; - } - /** - *

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.Container); - /** - * Copy Constructor with compare. - * - * @param container A container to be copied. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: base.Container, 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); - /** - * @hidden - */ - protected construct_from_array(items: Array): void; - /** - * @hidden - */ - protected construct_from_container(container: base.IContainer): void; - /** - * @hidden - */ - protected construct_from_range(begin: Iterator, end: Iterator): void; - /** - *

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 { - /** - *

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 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 { - /** - * Type definition of {@link SetContainer}'s {@link SetIterator iterator}. - */ - static iterator: typeof SetIterator; - /** - *

{@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}.

- */ - protected data_: List; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from elements. - */ - constructor(items: Array); - /** - * Copy Constructor. - */ - constructor(container: IContainer); - /** - * Construct from range iterators. - */ - constructor(begin: Iterator, end: Iterator); - /** - * @hidden - */ - protected init(): void; - /** - * @hidden - */ - protected construct_from_array(items: Array): void; - /** - * @hidden - */ - protected construct_from_container(container: IContainer): void; - /** - * @hidden - */ - protected construct_from_range>(begin: InputIterator, end: InputIterator): void; - /** - * @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_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; - } -} -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 + 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; - /** - * @inheritdoc - */ - swap(obj: SetIterator): void; } /** - *

A reverse-iterator of Set.

+ *

Default hash function for number.

* - *

+ *

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

* - * @param Type of the elements. + *

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. + *

* - * @author Jeongho Nam + * @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. */ - class SetReverseIterator extends ReverseIterator, SetReverseIterator> { - constructor(base: SetIterator); - /** - * @inheritdoc - */ - protected create_neighbor(): SetReverseIterator; - } -} -declare namespace std.base { + function hash(val: number): number; /** - *

An abstract set.

+ *

Default hash function for string.

* - *

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

+ *

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

* - *

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.

+ *

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. + *

* - *

{@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}.

+ * @param str A string to be hashed. * - *

- * - *

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 + * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. */ - abstract class UniqueSet extends SetContainer { - /** - * @inheritdoc - */ - count(key: T): number; - /** - *

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; - /** - * @inheritdoc - */ - swap(obj: UniqueSet): void; - } -} -declare namespace std.base { + function hash(str: string): number; /** - *

An abstract set.

+ *

Default hash function for Object.

* - *

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

+ *

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

* - *

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.

+ *

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. + *

* - *

{@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}.

+ *

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. * - *

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 + * @return Returns a hash value for its argument, as a value of type number. The number is an unsigned integer. */ - 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; - /** - * @inheritdoc - */ - swap(obj: MultiSet): void; - } + 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 { /** - *

Hashed, unordered set.

+ *

Bind function arguments.

* - *

{@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.

+ *

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

* - *

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.

+ *

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). + *
  • + *
* - *

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).

+ *

Calling the returned object returns the same type as fn.

* - *

{@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.

+ * @param fn A function object, pointer to function or pointer to member. + * @param args List of arguments to bind: either values, or {@link placeholders}. * - *

- * - *

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 + * @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. */ - class HashSet extends base.UniqueSet { - private hash_buckets_; - /** - * @hidden - */ - protected init(): void; - /** - * @hidden - */ - protected construct_from_array(items: Array): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(val: T): 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; - /** - * @inheritdoc - */ - swap(obj: base.UniqueSet): void; - /** - * @hidden - */ - private swap_tree_set(obj); + 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; } /** - *

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 HashSet} 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 + * Replaced by the first argument in the function call. */ - class HashMultiSet extends base.MultiSet { - private hash_buckets_; - /** - * @hidden - */ - protected init(): void; - /** - * @hidden - */ - protected construct_from_array(items: Array): void; - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(val: T): SetIterator; - /** - * @inheritdoc - */ - count(val: T): number; - /** - * @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; - /** - * @inheritdoc - */ - swap(obj: base.MultiSet): void; - /** - * @hidden - */ - private swap_tree_set(obj); - } + 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 { /** @@ -3950,6 +5202,246 @@ declare namespace std.base { swap(obj: MultiMap): void; } } +declare namespace std.base { + /** + *

Common interface for hash map.

+ * + *

{@link IHashMap}s are associative containers that store elements formed by the combination of + * a key value and a mapped value.

+ * + *

In an {@link IHashMap}, 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 IHashMap} 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.
+ *
+ * + * @param Type of the key values. + * Each element in an {@link IHashMap} is identified by a key value. + * @param Type of the mapped value. + * Each element in an {@link IHashMap} is used to store some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/unordered_map + * @author Jeongho Nam + */ + interface IHashMap { + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the {@link IHashMap}.

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * container, until invalidated.

+ * + * @return An iterator to the first element in the container. + */ + begin(): MapIterator; + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in one of buckets in the {@link IHashMap}.

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * bucket, until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the first element in the bucket. + */ + begin(index: number): MapIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @return An iterator to the element past the end of the container. + */ + end(): MapIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the element past the end of the bucket. + */ + end(index: number): MapIterator; + rbegin(): MapReverseIterator; + rbegin(index: number): MapReverseIterator; + rend(): MapReverseIterator; + rend(index: number): MapReverseIterator; + /** + *

Return number of buckets.

+ * + *

Returns the number of buckets in the {@link IHashMap} container.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key.

+ * + *

The number of buckets influences directly the {@link load_factor load factor} of the container's hash + * table (and thus the probability of collision). The container automatically increases the number of buckets to + * keep the load factor below a specific threshold (its {@link max_load_factor}), causing a {@link rehash} each + * time the number of buckets needs to be increased.

+ * + * @return The current amount of buckets. + */ + bucket_count(): number; + /** + *

Return bucket size.

+ * + *

Returns the number of elements in bucket n.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the hash + * value of their key.

+ * + *

The number of elements in a bucket influences the time it takes to access a particular element in the + * bucket. The container automatically increases the number of buckets to keep the {@link load_cator load factor} + * (which is the average bucket size) below its {@link max_load_factor}.

+ * + * @param n Bucket number. This shall be lower than {@link bucket_count}. + * + * @return The number of elements in bucket n. + */ + bucket_size(n: number): number; + /** + *

Get maximum load factor.

+ * + *

Returns the current maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @return The current load factor. + */ + max_load_factor(): number; + /** + *

Set maximum load factor.

+ * + *

Sets z as the cnew maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @param z The new maximum load factor. + */ + max_load_factor(z: number): void; + /** + *

Locate element's bucket.

+ * + *

Returns the bucket number where the element with key is located.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key. Buckets are numbered from 0 to ({@link bucket_count} - 1).

+ * + *

Individual elements in a bucket can be accessed by means of the range iterators returned by + * {@link begin} and {@link end}.

+ * + * @param key Key whose bucket is to be located. + */ + bucket(key: Key): number; + /** + *

Request a capacity change.

+ * + *

Sets the number of buckets in the container ({@link bucket_count}) to the most appropriate to contain at + * least n elements.

+ * + *

If n is greater than the current {@link bucket_count} multiplied by the {@link max_load_factor}, + * the container's {@link bucket_count} is increased and a {@link rehash} is forced.

+ * + *

If n is lower than that, the function may have no effect.

+ * + * @param n The number of elements requested as minimum capacity. + */ + reserve(n: number): void; + /** + *

Set number of buckets.

+ * + *

Sets the number of buckets in the container to n or more.

+ * + *

If n is greater than the current number of buckets in the container ({@link bucket_count}), a + * {@link HashBuckets.rehash rehash} is forced. The new {@link bucket_count bucket count} can either be equal or + * greater than n.

+ * + *

If n is lower than the current number of buckets in the container ({@link bucket_count}), the + * function may have no effect on the {@link bucket_count bucket count} and may not force a + * {@link HashBuckets.rehash rehash}.

+ * + *

A {@link HashBuckets.rehash rehash} is the reconstruction of the hash table: All the elements in the + * container are rearranged according to their hash value into the new set of buckets. This may alter the order + * of iteration of elements within the container.

+ * + *

{@link HashBuckets.rehash Rehashes} are automatically performed by the container whenever its + * {@link load_factor load factor} is going to surpass its {@link max_load_factor} in an operation.

+ * + *

Notice that this function expects the number of buckets as argument. A similar function exists, + * {@link reserve}, that expects the number of elements in the container as argument.

+ * + * @param n The minimum number of buckets for the container hash table. + */ + rehash(n: number): void; + } +} declare namespace std { /** *

Hashed, unordered map.

@@ -3998,7 +5490,7 @@ declare namespace std { * @reference http://www.cplusplus.com/reference/unordered_map/unordered_map * @author Jeongho Nam */ - class HashMap extends base.UniqueMap { + class HashMap extends base.UniqueMap implements base.IHashMap { private hash_buckets_; /** * @hidden @@ -4016,6 +5508,66 @@ declare namespace std { * @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 */ @@ -4045,6 +5597,8 @@ declare namespace std { */ private swap_hash_map(obj); } +} +declare namespace std { /** *

Hashed, unordered Multimap.

* @@ -4117,6 +5671,66 @@ declare namespace std { * @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 */ @@ -4147,25 +5761,20 @@ declare namespace std { private swap_hash_multimap(obj); } } -declare namespace std { +declare namespace std.base { /** - *

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

+ *

An abstract set.

* - *

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

+ *

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

* - *

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

+ *

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.

* - *

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.

+ *

{@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}.

* *

* @@ -4177,10 +5786,371 @@ declare namespace std { * position in the container. * * - *
Ordered
+ *
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 { + /** + * Type definition of {@link SetContainer}'s {@link SetIterator iterator}. + */ + static iterator: typeof SetIterator; + /** + *

{@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}.

+ */ + protected data_: List; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from elements. + */ + constructor(items: Array); + /** + * Copy Constructor. + */ + constructor(container: IContainer); + /** + * Construct from range iterators. + */ + constructor(begin: Iterator, end: Iterator); + /** + * @hidden + */ + protected init(): void; + /** + * @hidden + */ + protected construct_from_array(items: Array): void; + /** + * @hidden + */ + protected construct_from_container(container: IContainer): void; + /** + * @hidden + */ + protected construct_from_range>(begin: InputIterator, end: InputIterator): void; + /** + * @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_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; + } +} +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> { + constructor(base: SetIterator); + /** + * @inheritdoc + */ + protected create_neighbor(): 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 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
*
- * The elements in the container follow a strict order at all times. All inserted elements are - * given a position in this order. + * Elements in associative containers are referenced by their key and not by their absolute + * position in the container. *
* *
Set
@@ -4190,66 +6160,412 @@ declare namespace std { *
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. + * @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). * - * @reference http://www.cplusplus.com/reference/set/set * @author Jeongho Nam */ - class TreeSet extends base.UniqueSet { + abstract class UniqueSet extends SetContainer { /** - * RB-Tree+ object for implemeting the {@link TreeSet}. + * @inheritdoc */ - private tree_; + count(key: T): number; /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. + *

Insert an element.

* - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (left: T, right: T) => boolean); - /** - * Contruct from elements. + *

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

* - * @param array Elements to be contained. - */ - constructor(array: Array); - /** - * Contruct from elements with compare. + *

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).

* - * @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. + *

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

* - * @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 key Value to be inserted as an element. * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. + * @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. */ - constructor(begin: Iterator, end: Iterator); + insert(val: T): Pair, boolean>; /** - * 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. + * @inheritdoc */ - constructor(begin: Iterator, end: Iterator, compare: (left: T, right: T) => boolean); + insert(hint: SetIterator, val: T): SetIterator; + /** + * @inheritdoc + */ + insert(hint: SetReverseIterator, val: T): SetReverseIterator; + /** + * @inheritdoc + */ + insert>(begin: InputIterator, end: InputIterator): void; + /** + * @inheritdoc + */ + swap(obj: UniqueSet): 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.
+ * + *
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; + /** + * @inheritdoc + */ + swap(obj: MultiSet): void; + } +} +declare namespace std.base { + /** + *

A common interface for hash set.

+ * + *

{@link IHashSet}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 IHashSet}, 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 IHashSet} cannot be + * modified once in the container - they can be inserted and removed, though.

+ * + *

Internally, the elements in the {@link IHashSet} 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 IHashSet} 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.
+ *
+ * + * @param Type of the elements. + * Each element in an {@link IHashSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set + * @author Jeongho Nam + */ + interface IHashSet { + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the {@link IHashSet}.

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * container, until invalidated.

+ * + * @return An iterator to the first element in the container. + */ + begin(): SetIterator; + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in one of buckets in the {@link IHashSet}.

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * bucket, until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the first element in the bucket. + */ + begin(index: number): SetIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @return An iterator to the element past the end of the container. + */ + end(): SetIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the element past the end of the bucket. + */ + end(index: number): SetIterator; + rbegin(): SetReverseIterator; + rbegin(index: number): SetReverseIterator; + rend(): SetReverseIterator; + rend(index: number): SetReverseIterator; + /** + *

Return number of buckets.

+ * + *

Returns the number of buckets in the {@link IHashSet} container.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key.

+ * + *

The number of buckets influences directly the {@link load_factor load factor} of the container's hash + * table (and thus the probability of collision). The container automatically increases the number of buckets to + * keep the load factor below a specific threshold (its {@link max_load_factor}), causing a {@link rehash} each + * time the number of buckets needs to be increased.

+ * + * @return The current amount of buckets. + */ + bucket_count(): number; + /** + *

Return bucket size.

+ * + *

Returns the number of elements in bucket n.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the hash + * value of their key.

+ * + *

The number of elements in a bucket influences the time it takes to access a particular element in the + * bucket. The container automatically increases the number of buckets to keep the {@link load_cator load factor} + * (which is the average bucket size) below its {@link max_load_factor}.

+ * + * @param n Bucket number. This shall be lower than {@link bucket_count}. + * + * @return The number of elements in bucket n. + */ + bucket_size(n: number): number; + /** + *

Get maximum load factor.

+ * + *

Returns the current maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @return The current load factor. + */ + max_load_factor(): number; + /** + *

Set maximum load factor.

+ * + *

Sets z as the cnew maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @param z The new maximum load factor. + */ + max_load_factor(z: number): void; + /** + *

Locate element's bucket.

+ * + *

Returns the bucket number where the element with key is located.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key. Buckets are numbered from 0 to ({@link bucket_count} - 1).

+ * + *

Individual elements in a bucket can be accessed by means of the range iterators returned by + * {@link begin} and {@link end}.

+ * + * @param key Key whose bucket is to be located. + */ + bucket(key: T): number; + /** + *

Request a capacity change.

+ * + *

Sets the number of buckets in the container ({@link bucket_count}) to the most appropriate to contain at + * least n elements.

+ * + *

If n is greater than the current {@link bucket_count} multiplied by the {@link max_load_factor}, + * the container's {@link bucket_count} is increased and a {@link rehash} is forced.

+ * + *

If n is lower than that, the function may have no effect.

+ * + * @param n The number of elements requested as minimum capacity. + */ + reserve(n: number): void; + /** + *

Set number of buckets.

+ * + *

Sets the number of buckets in the container to n or more.

+ * + *

If n is greater than the current number of buckets in the container ({@link bucket_count}), a + * {@link HashBuckets.rehash rehash} is forced. The new {@link bucket_count bucket count} can either be equal or + * greater than n.

+ * + *

If n is lower than the current number of buckets in the container ({@link bucket_count}), the + * function may have no effect on the {@link bucket_count bucket count} and may not force a + * {@link HashBuckets.rehash rehash}.

+ * + *

A {@link HashBuckets.rehash rehash} is the reconstruction of the hash table: All the elements in the + * container are rearranged according to their hash value into the new set of buckets. This may alter the order + * of iteration of elements within the container.

+ * + *

{@link HashBuckets.rehash Rehashes} are automatically performed by the container whenever its + * {@link load_factor load factor} is going to surpass its {@link max_load_factor} in an operation.

+ * + *

Notice that this function expects the number of buckets as argument. A similar function exists, + * {@link reserve}, that expects the number of elements in the container as argument.

+ * + * @param n The minimum number of buckets for the container hash table. + */ + rehash(n: number): void; + } +} +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 { + private hash_buckets_; + /** + * @hidden + */ + protected init(): void; + /** + * @hidden + */ + protected construct_from_array(items: Array): void; /** * @inheritdoc */ @@ -4257,78 +6573,74 @@ declare namespace std { /** * @inheritdoc */ - find(val: T): SetIterator; + find(key: T): SetIterator; /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the container which is not considered to go - * before val (i.e., either it is equivalent or goes after).

- * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(element, val) would return false.

- * - *

If the {@link Set} class is instantiated with the default comparison type ({@link less}), the - * function returns an iterator to the first element that is not less than val.

- * - *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, - * except in the case that the {@link Set} contains an element equivalent to val: In this case - * {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} returns - * an iterator pointing to the next element.

- * - * @param val Value to compare. - * - * @return An iterator to the the first element in the container which is not considered to go before - * val, or {@link Set.end} if all elements are considered to go before val. + * @inheritdoc */ - lower_bound(val: T): SetIterator; + begin(): SetIterator; /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the container which is not considered to go - * after val.

- * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(element, val) would return true.

- * - *

If the {@link Set} class is instantiated with the default comparison type ({@link less}), the - * function returns an iterator to the first element that is greater than val.

- * - *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except - * in the case that the {@link Set} contains an element equivalent to val: In this case - * {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} returns - * an iterator pointing to the next element.

- * - * @param val Value to compare. - * - * @return An iterator to the the first element in the container which is not considered to go before - * val, or {@link Set.end} if all elements are considered to go after val. + * @inheritdoc */ - upper_bound(val: T): SetIterator; + begin(index: number): SetIterator; /** - *

Get range of equal elements.

- * - *

Because all elements in a {@link Set} container are unique, the range returned will contain a - * single element at most.

- * - *

If no matches are found, the range returned has a length of zero, with both iterators pointing to - * the first element that is considered to go after val according to the container's - * internal comparison object (key_comp).

- * - *

Two elements of a {@link Set} 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). - *

- * - * @param val Value to search for. - * - * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of - * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound - * (the same as {@link upper_bound}). + * @inheritdoc */ - equal_range(val: T): Pair, SetIterator>; + 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 @@ -4351,60 +6663,1029 @@ declare namespace std { */ private swap_tree_set(obj); } +} +declare namespace std { /** - *

Tree-structured multiple-key set.

+ *

Hashed, unordered Multiset.

* - *

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

+ *

{@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 HashSet} containers, + * but allowing different elements to 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

+ *

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 a {@link TreeMultiSet TreeMultiSets} are always sorted following a strict - * weak ordering criterion indicated by its internal comparison method (of {@link IComparable.less less}).

+ *

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).

* - *

{@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.

+ *

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. - *
+ *
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. - *
+ *
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
- *
Multiple elements in the container can have equivalent keys.
+ *
The container can hold multiple elements with 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). + * @param Type of the elements. + * Each element in an {@link UnorderedMultiSet} is also identified by this value.. * - * @reference http://www.cplusplus.com/reference/set/multiset + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_multiset * @author Jeongho Nam */ - class TreeMultiSet extends base.MultiSet { + class HashMultiSet extends base.MultiSet { + private hash_buckets_; /** - * RB-Tree+ object for implemeting the {@link TreeMultiSet}. + * @hidden */ - private tree_; + protected init(): void; + /** + * @hidden + */ + protected construct_from_array(items: Array): void; + /** + * @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; + /** + * @inheritdoc + */ + swap(obj: base.MultiSet): void; + /** + * @hidden + */ + private swap_tree_set(obj); + } +} +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 { + /** + * An iterator of beginning. + */ + protected begin_: ListIterator; + /** + * An iterator of end. + */ + protected end_: ListIterator; + /** + * Number of elements in the {@link List}. + */ + protected size_: number; + /** + *

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: base.IContainer); + /** + *

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; + /** + * @inheritdoc + */ + swap(obj: base.IContainer): void; + /** + * @hidden + */ + private swap_list(obj); + } +} +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); + /** + * @inheritdoc + */ + set_prev(it: ListIterator): void; + /** + * @inheritdoc + */ + set_next(next: ListIterator): void; + private list(); + /** + * @inheritdoc + */ + prev(): ListIterator; + /** + * @inheritdoc + */ + next(): ListIterator; + /** + * @inheritdoc + */ + advance(step: number): ListIterator; + /** + * @inheritdoc + */ + 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> { + constructor(base: ListIterator); + /** + * @inheritdoc + */ + protected create_neighbor(): ListReverseIterator; + /** + * @inheritdoc + */ + value: T; + } +} +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 { + /** + *

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. */ @@ -4447,7 +7728,7 @@ declare namespace std { */ constructor(begin: Iterator, end: Iterator); /** - * Construct from range and compare. + * 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. @@ -4455,3621 +7736,215 @@ declare namespace std { */ constructor(begin: Iterator, end: Iterator, compare: (left: T, right: T) => boolean); /** - * @inheritdoc + * @hidden */ - clear(): void; - /** - * @inheritdoc - */ - find(val: T): SetIterator; - /** - * @inheritdoc - */ - count(val: T): number; - /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the container which is not considered to - * go before val (i.e., either it is equivalent or goes after).

- * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(element,val) would return false.

- * - *

If the {@link TreeMultiSet} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element that is not less than val.

- - *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except - * in the case that the {@link TreeMultiSet} contains elements equivalent to val: In this case - * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas - * {@link upper_bound} returns an iterator pointing to the element following the last.

- * - * @param val Value to compare. - * - * @return An iterator to the the first element in the container which is not considered to go before - * val, or {@link TreeMultiSet.end} if all elements are considered to go before val. - */ - lower_bound(val: T): SetIterator; - /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the container which is considered to go after - * val.

- - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(val,element) would return true.

- - *

If the {@code TreeMultiSet} class is instantiated with the default comparison type (less), the - * function returns an iterator to the first element that is greater than val.

- * - *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except - * in the case that the {@TreeMultiSet} contains elements equivalent to val: In this case - * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas - * {@link upper_bound} returns an iterator pointing to the element following the last.

- * - * @param val Value to compare. - * - * @return An iterator to the the first element in the container which is considered to go after - * val, or {@link TreeMultiSet.end} if no elements are considered to go after val. - */ - upper_bound(val: T): SetIterator; - /** - *

Get range of equal elements.

- * - *

Returns the bounds of a range that includes all the elements in the container that are equivalent - * to val.

- * - *

If no matches are found, the range returned has a length of zero, with both iterators pointing to - * the first element that is considered to go after val according to the container's - * internal comparison object (key_comp).

- * - *

Two elements of a multiset 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).

- * - * @param key Value to search for. - * - * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of - * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound - * (the same as {@link upper_bound}). - */ - equal_range(val: T): Pair, SetIterator>; + protected construct_from_array(items: Array): void; /** * @hidden */ - protected insert_by_val(val: T): any; + protected construct_from_container(container: base.IContainer): void; /** * @hidden */ - protected insert_by_hint(hint: SetIterator, val: T): SetIterator; + protected construct_from_range(begin: Iterator, end: Iterator): void; /** - * @hidden + *

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 */ - protected insert_by_range>(first: InputIterator, last: InputIterator): void; + size(): number; /** - * @inheritdoc + *

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.

*/ - protected handle_insert(first: SetIterator, last: SetIterator): void; + empty(): boolean; /** - * @inheritdoc + *

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}. */ - protected handle_erase(first: SetIterator, last: SetIterator): void; + top(): T; /** - * @inheritdoc + *

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. */ - swap(obj: base.MultiSet): void; + push(val: T): void; /** - * @hidden + *

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.

*/ - private swap_tree_set(obj); + 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 { /** - *

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

+ *

LIFO stack.

* - *

{@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.

+ *

{@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

* - *

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:

+ *

{@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}.

* - *

typedef Pair value_type;

+ *

{@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:

* - *

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 { - /** - * RB-Tree+ object for implemeting the {@link TreeMap}. - */ - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (left: Key, right: 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: (left: Key, right: 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: (left: Key, right: Key) => boolean); - /** - * Copy Constructor. - * - * @param container Another map to copy. - */ - constructor(container: base.MapContainer); - /** - * Copy Constructor. - * - * @param container Another map to copy. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: base.MapContainer, compare: (left: Key, right: 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: (left: Key, right: Key) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: Key): MapIterator; - /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the container whose key is not considered to - * go before k (i.e., either it is equivalent or goes after).

- * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(k, element_key) would return false.

- * - *

If the {@link TreeMap} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element whose key is not less than k

. - * - *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except - * in the case that the {@link TreeMap} contains an element with a key equivalent to k: In this - * case, {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} - * returns an iterator pointing to the next element.

- * - * @param k Key to search for. - * - * @return An iterator to the the first element in the container whose key is not considered to go before - * k, or {@link TreeMap.end} if all keys are considered to go before k. - */ - lower_bound(key: Key): MapIterator; - /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the container whose key is considered to - * go after k

. - * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(k, element_key) would return true.

- * - *

If the {@link TreeMap} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element whose key is greater than k

. - * - *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except - * in the case that the map contains an element with a key equivalent to k: In this case - * {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} returns an - * iterator pointing to the next element.

- * - * @param k Key to search for. - * - * @return An iterator to the the first element in the container whose key is considered to go after - * k, or {@link TreeMap.end} if no keys are considered to go after k. - */ - upper_bound(key: Key): MapIterator; - /** - *

Get range of equal elements.

- * - *

Returns the bounds of a range that includes all the elements in the container which have a key - * equivalent to k

. - * - *

Because the elements in a {@link TreeMap} container have unique keys, the range returned will - * contain a single element at most.

- * - *

If no matches are found, the range returned has a length of zero, with both iterators pointing to - * the first element that has a key considered to go after k according to the container's internal - * comparison object (key_comp).

- * - *

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

- * - * @param k Key to search for. - * - * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of - * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound - * (the same as {@link upper_bound}). - */ - 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; - /** - * @inheritdoc - */ - swap(obj: base.UniqueMap): void; - /** - * @hidden - */ - private swap_tree_map(obj); - } - /** - *

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.

- * - *

- * - *

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 { - private tree_; - /** - * Default Constructor. - */ - constructor(); - /** - * Construct from compare. - * - * @param compare A binary predicate determines order of elements. - */ - constructor(compare: (left: Key, right: 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: (left: Key, right: 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: (left: Key, right: Key) => boolean); - /** - * Copy Constructor. - * - * @param container Another map to copy. - */ - constructor(container: base.MapContainer); - /** - * Copy Constructor. - * - * @param container Another map to copy. - * @param compare A binary predicate determines order of elements. - */ - constructor(container: base.MapContainer, compare: (left: Key, right: 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: (left: Key, right: Key) => boolean); - /** - * @inheritdoc - */ - clear(): void; - /** - * @inheritdoc - */ - find(key: Key): MapIterator; - /** - * @inheritdoc - */ - count(key: Key): number; - /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the container whose key is not considered to - * go before k (i.e., either it is equivalent or goes after).

- * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(k, element_key) would return false.

- * - *

If the {@link TreeMultiMap} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element whose key is not less than k

. - * - *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except - * in the case that the {@link TreeMultiMap} contains an element with keys equivalent to k: - * In this case, {@link lower_bound} returns an iterator pointing to the first of such elements, - * whereas {@link upper_bound} returns an iterator pointing to the element following the last.

- * - * @param k Key to search for. - * - * @return An iterator to the the first element in the container whose key is not considered to go before - * k, or {@link TreeMultiMap.end} if all keys are considered to go before k. - */ - lower_bound(key: Key): MapIterator; - /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the container whose key is considered to - * go after k

. - * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(k, element_key) would return true.

- * - *

If the {@link TreeMultiMap} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element whose key is greater than k

. - * - *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except - * in the case that the {@link TreeMultiMap} contains an element with keys equivalent to k: - * In this case {@link lower_bound} returns an iterator pointing to first of such element, whereas - * {@link upper_bound} returns an iterator pointing to the element following the last.

- * - * @param k Key to search for. - * - * @return An iterator to the the first element in the container whose key is considered to go after - * k, or {@link TreeMultiMap.end} if no keys are considered to go after k. - */ - upper_bound(key: Key): MapIterator; - /** - *

Get range of equal elements.

- * - *

Returns the bounds of a range that includes all the elements in the container which have a key - * equivalent to k

. - * - *

If no matches are found, the range returned has a length of zero, with both iterators pointing to - * the first element that has a key considered to go after k according to the container's internal - * comparison object (key_comp).

- * - *

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

- * - * @param k Key to search for. - * - * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of - * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound - * (the same as {@link upper_bound}). - */ - 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; - /** - * @inheritdoc - */ - swap(obj: base.MultiMap): void; - /** - * @hidden - */ - private swap_tree_multimap(obj); - } -} -declare namespace std { - /** - *

Apply function to range.

- * - *

Applies function fn to each of the elements in the range [first, last).

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @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; - /** - *

Test condition on all elements in range.

- * - *

Returns true if pred returns true for all the elements in the range - * [first, last) or if the range is {@link IContainer.empty empty}, and false otherwise. - *

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to - * boolean. The value returned indicates whether the element fulfills the condition - * checked by this function. The function shall not modify its argument. - * - * @return true if pred returns true for all the elements in the range or if the range is - * {@link IContainer.empty empty}, and false otherwise. - */ - function all_of>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; - /** - *

Test if any element in range fulfills condition.

- * - *

Returns true if pred returns true for any of the elements in the range - * [first, last), and false otherwise.

- * - *

If [first, last) is an {@link IContainer.empty empty} range, the function returns - * false.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to - * boolean. The value returned indicates whether the element fulfills the condition - * checked by this function. The function shall not modify its argument. - * - * @return true if pred returns true for any of the elements in the range - * [first, last), and false otherwise. If [first, last) is an - * {@link IContainer.empty empty} range, the function returns false. - */ - function any_of>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; - /** - *

Test if no elements fulfill condition.

- * - *

Returns true if pred returns false for all the elements in the range - * [first, last) or if the range is {@link IContainer.empty empty}, and false otherwise. - *

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to - * boolean. The value returned indicates whether the element fulfills the condition - * checked by this function. The function shall not modify its argument. - * - * @return true if pred returns false for all the elements in the range - * [first, last) or if the range is {@link IContainer.empty empty}, and false - * otherwise. - */ - function none_of>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; - /** - *

Test whether the elements in two ranges are equal.

- * - *

Compares the elements in the range [first1, last1) with those in the range beginning at - * first2, and returns true if all of the elements in both ranges match.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to - * as many elements of this sequence as those in the range [first1, last1). - * - * @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; - /** - *

Test whether the elements in two ranges are equal.

- * - *

Compares the elements in the range [first1, last1) with those in the range beginning at - * first2, and returns true if all of the elements in both ranges match.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to - * as many elements of this sequence as those in the range [first1, last1). - * @param pred Binary function that accepts two elements as argument (one of each of the two sequences, in the same - * order), and returns a value convertible to bool. The value returned indicates whether - * the elements are considered to match in the context of this function. - * - * @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; - /** - *

Test whether range is permutation of another.

- * - *

Compares the elements in the range [first1, last1) with those in the range beginning at - * first2, and returns true if all of the elements in both ranges match, even in a different - * order.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to - * as many elements of this sequence as those in the range [first1, last1). - * - * @return true if all the elements in the range [first1, last1) compare equal to those - * of the range starting at first2 in any order, and false otherwise. - */ - function is_permutation, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2): boolean; - /** - *

Test whether range is permutation of another.

- * - *

Compares the elements in the range [first1, last1) with those in the range beginning at - * first2, and returns true if all of the elements in both ranges match, even in a different - * order.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to - * as many elements of this sequence as those in the range [first1, last1). - * @param pred Binary function that accepts two elements as argument (one of each of the two sequences, in the same - * order), and returns a value convertible to bool. The value returned indicates whether - * the elements are considered to match in the context of this function. - * - * @return true if all the elements in the range [first1, last1) compare equal to those - * of the range starting at first2 in any order, and false otherwise. - */ - function is_permutation, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, pred: (x: T, y: T) => boolean): boolean; - /** - *

Lexicographical less-than comparison.

- * - *

Returns true if the range [first1, last1) compares lexicographically less - * than the range [first2, last2).

- * - *

A lexicographical comparison is the kind of comparison generally used to sort words alphabetically in - * dictionaries; It involves comparing sequentially the elements that have the same position in both ranges against - * each other until one element is not equivalent to the other. The result of comparing these first non-matching - * elements is the result of the lexicographical comparison.

- * - *

If both sequences compare equal until one of them ends, the shorter sequence is lexicographically less - * than the longer one.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. - * @param last2 An {@link Iterator} to the final position of the second sequence. The ranged used is - * [first2, last2). - * - * @return true if the first range compares lexicographically less than than the second. - * false otherwise (including when all the elements of both ranges are equivalent). - */ - function lexicographical_compare, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): boolean; - /** - *

Lexicographical comparison.

- * - *

Returns true if the range [first1, last1) compares lexicographically - * relationship than the range [first2, last2).

- * - *

A lexicographical comparison is the kind of comparison generally used to sort words alphabetically in - * dictionaries; It involves comparing sequentially the elements that have the same position in both ranges against - * each other until one element is not equivalent to the other. The result of comparing these first non-matching - * elements is the result of the lexicographical comparison.

- * - *

If both sequences compare equal until one of them ends, the shorter sequence is lexicographically - * relationship than the longer one.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. - * @param last2 An {@link Iterator} to the final position of the second sequence. The ranged used is - * [first2, last2). - * @param compare Binary function that accepts two arguments of the types pointed by the iterators, and returns a - * value convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. - * - * @return true if the first range compares lexicographically relationship than than the - * second. false otherwise (including when all the elements of both ranges are equivalent). - */ - function lexicographical_compare, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, compare: (x: T, y: T) => boolean): boolean; - /** - *

Find value in range.

- * - *

Returns an iterator to the first element in the range [first, last) that compares equal to - * val. If no such element is found, the function returns last.

- * - *

The function uses {@link equal_to equal_to} to compare the individual elements to val.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param val Value to search for in the range. - * - * @return An {@link Iterator} to the first element in the range that compares equal to val. If no elements - * match, the function returns last. - */ - function find>(first: InputIterator, last: InputIterator, val: T): InputIterator; - /** - *

Find element in range.

- * - *

Returns an iterator to the first element in the range [first, last) for which pred returns - * true. If no such element is found, the function returns last.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument and returns a value convertible - * to bool. The value returned indicates whether the element is considered a match in - * the context of this function. The function shall not modify its argument. - * - * @return An {@link Iterator} to the first element in the range for which pred does not return - * false. If pred is false for all elements, the function returns - * last. - */ - function find_if>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): InputIterator; - /** - *

Find element in range.

- * - *

Returns an iterator to the first element in the range [first, last) for which pred returns - * true. If no such element is found, the function returns last.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument and returns a value convertible - * to bool. The value returned indicates whether the element is considered a match in - * the context of this function. The function shall not modify its argument. - * - * @return An {@link Iterator} to the first element in the range for which pred returns false. - * If pred is true for all elements, the function returns last. - */ - function find_if_not>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): InputIterator; - /** - *

Find last subsequence in range.

- * - *

Searches the range [first1, last1) for the last occurrence of the sequence defined by - * [first2, last2), and returns an {@link Iterator} to its first element, or last1,/i> if no - * occurrences are found.

- * - *

The elements in both ranges are compared sequentially using {@link equal_to}: A subsequence of - * [first1, last1) is considered a match only when this is true for all the elements of - * [first2, last2).

- * - *

This function returns the last of such occurrences. For an algorithm that returns the first instead, see - * {@link search}.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. - * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used - * is [first2, last2). - * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the - * same order), and returns a value convertible to bool. The value returned indicates - * whether the elements are considered to match in the context of this function. - * - * @return An {@link Iterator} to the first element of the last occurrence of [first2, last2) in - * [first1, last1). If the sequence is not found, the function returns ,i>last1
. Otherwise - * [first2, last2) is an empty range, the function returns last1. - */ - function find_end, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): Iterator1; - /** - *

Find last subsequence in range.

- * - *

Searches the range [first1, last1) for the last occurrence of the sequence defined by - * [first2, last2), and returns an {@link Iterator} to its first element, or last1,/i> if no - * occurrences are found.

- * - *

The elements in both ranges are compared sequentially using pred: A subsequence of - * [first1, last1) is considered a match only when this is true for all the elements of - * [first2, last2).

- * - *

This function returns the last of such occurrences. For an algorithm that returns the first instead, see - * {@link search}.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. - * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used - * is [first2, last2). - * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the - * same order), and returns a value convertible to bool. The value returned indicates - * whether the elements are considered to match in the context of this function. - * - * @return An {@link Iterator} to the first element of the last occurrence of [first2, last2) in - * [first1, last1). If the sequence is not found, the function returns ,i>last1
. Otherwise - * [first2, last2) is an empty range, the function returns last1. - */ - function find_end, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, pred: (x: T, y: T) => boolean): Iterator1; - /** - *

Find element from set in range.

- * - *

Returns an iterator to the first element in the range [first1, last1) that matches any of the - * elements in [first2, last2). If no such element is found, the function returns last1.

- * - *

The elements in [first1, last1) are sequentially compared to each of the values in - * [first2, last2) using {@link equal_to}, until a pair matches.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. - * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used - * is [first2, last2). - * - * @return An {@link Iterator} to the first element in [first1, last1) that is part of - * [first2, last2). If no matches are found, the function returns last1. - */ - function find_first_of, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): Iterator1; - /** - *

Find element from set in range.

- * - *

Returns an iterator to the first element in the range [first1, last1) that matches any of the - * elements in [first2, last2). If no such element is found, the function returns last1.

- * - *

The elements in [first1, last1) are sequentially compared to each of the values in - * [first2, last2) using pred, until a pair matches.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the element values to be searched for. - * @param last2 An {@link Iterator} to the final position of the element values to be searched for. The range used - * is [first2, last2). - * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the - * same order), and returns a value convertible to bool. The value returned indicates - * whether the elements are considered to match in the context of this function. - * - * @return An {@link Iterator} to the first element in [first1, last1) that is part of - * [first2, last2). If no matches are found, the function returns last1. - */ - function find_first_of, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, pred: (x: T, y: T) => boolean): Iterator1; - /** - *

Find equal adjacent elements in range.

- * - *

Searches the range [first, last) for the first occurrence of two consecutive elements that match, - * and returns an {@link Iterator} to the first of these two elements, or last if no such pair is found.

- * - *

Two elements match if they compare equal using {@link equal_to}.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * - * @return An {@link Iterator} to the first element of the first pair of matching consecutive elements in the range - * [first, last). If no such pair is found, the function returns last. - */ - function adjacent_find>(first: InputIterator, last: InputIterator): InputIterator; - /** - *

Find equal adjacent elements in range.

- * - *

Searches the range [first, last) for the first occurrence of two consecutive elements that match, - * and returns an {@link Iterator} to the first of these two elements, or last if no such pair is found.

- * - *

Two elements match if they compare equal using pred.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to - * bool. The value returned indicates whether the element is considered a match in the - * context of this function. The function shall not modify its argument. - * - * @return An {@link Iterator} to the first element of the first pair of matching consecutive elements in the range - * [first, last). If no such pair is found, the function returns last. - */ - function adjacent_find>(first: InputIterator, last: InputIterator, pred: (x: T, y: T) => boolean): InputIterator; - /** - *

Search range for subsequence.

- * - *

Searches the range [first1, last1) for the first occurrence of the sequence defined by - * [first2, last2), and returns an iterator to its first element, or last1 if no occurrences are - * found.

- * - *

The elements in both ranges are compared sequentially using {@link equal_to}: A subsequence of - * [first1, last1) is considered a match only when this is true for all the elements of - * [first2, last2).

- * - *

This function returns the first of such occurrences. For an algorithm that returns the last instead, see - * {@link find_end}.

- * - * @param first1 {@link Iterator Forward iterator} to the initial position of the searched sequence. - * @param last1 {@link Iterator Forward iterator} to the final position of the searched sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Forward iterator} to the initial position of the sequence to be searched for. - * @param last2 {@link Iterator Forward iterator} to the final position of the sequence to be searched for. The range - * used is [first2, last2). - * - * @return An iterator to the first element of the first occurrence of [first2, last2) in first1 - * and last1. If the sequence is not found, the function returns last1. Otherwise - * [first2, last2) is an empty range, the function returns first1. - */ - function search, ForwardIterator2 extends Iterator>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2, last2: ForwardIterator2): ForwardIterator1; - /** - *

Search range for subsequence.

- * - *

Searches the range [first1, last1) for the first occurrence of the sequence defined by - * [first2, last2), and returns an iterator to its first element, or last1 if no occurrences are - * found.

- * - *

The elements in both ranges are compared sequentially using pred: A subsequence of - * [first1, last1) is considered a match only when this is true for all the elements of - * [first2, last2).

- * - *

This function returns the first of such occurrences. For an algorithm that returns the last instead, see - * {@link find_end}.

- * - * @param first1 {@link Iterator Forward iterator} to the initial position of the searched sequence. - * @param last1 {@link Iterator Forward iterator} to the final position of the searched sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Forward iterator} to the initial position of the sequence to be searched for. - * @param last2 {@link Iterator Forward iterator} to the final position of the sequence to be searched for. The range - * used is [first2, last2). - * @param pred Binary function that accepts two elements as arguments (one of each of the two sequences, in the same - * order), and returns a value convertible to bool. The returned value indicates whether the elements are - * considered to match in the context of this function. The function shall not modify any of its - * arguments. - * - * @return An iterator to the first element of the first occurrence of [first2, last2) in - * [first1, last1). If the sequence is not found, the function returns last1. Otherwise - * [first2, last2) is an empty range, the function returns first1. - */ - function search, ForwardIterator2 extends Iterator>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2, last2: ForwardIterator2, pred: (x: T, y: T) => boolean): ForwardIterator1; - /** - *

Search range for elements.

- * - *

Searches the range [first, last) for a sequence of count elements, each comparing equal to - * val.

- * - *

The function returns an iterator to the first of such elements, or last if no such sequence is found. - *

- * - * @param first {@link Iterator Forward iterator} to the initial position of the searched sequence. - * @param last {@link Iterator Forward iterator} to the final position of the searched 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. - * @param count Minimum number of successive elements to match. - * @param val Individual value to be compared, or to be used as argument for {@link equal_to}. - * - * @return An iterator to the first element of the sequence. If no such sequence is found, the function returns - * last. - */ - function search_n>(first: ForwardIterator, last: ForwardIterator, count: number, val: T): ForwardIterator; - /** - *

Search range for elements.

- * - *

Searches the range [first, last) for a sequence of count elements, each comparing equal to - * val.

- * - *

The function returns an iterator to the first of such elements, or last if no such sequence is found. - *

- * - * @param first {@link Iterator Forward iterator} to the initial position of the searched sequence. - * @param last {@link Iterator Forward iterator} to the final position of the searched 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. - * @param count Minimum number of successive elements to match. - * @param val Individual value to be compared, or to be used as argument for pred. - * @param pred Binary function that accepts two arguments (one element from the sequence as first, and val as - * second), and returns a value convertible to bool. The value returned indicates whether the - * element is considered a match in the context of this function. The function shall not modify any of its - * arguments. - * - * @return An {@link Iterator} to the first element of the sequence. If no such sequence is found, the function - * returns last. - */ - function search_n>(first: ForwardIterator, last: ForwardIterator, count: number, val: T, pred: (x: T, y: T) => boolean): ForwardIterator; - /** - *

Return first position where two ranges differ.

- * - *

Compares the elements in the range [first1, last1) with those in the range beginning at - * first2, and returns the first element of both sequences that does not match.

- * - *

The function returns a {@link Pair} of {@link iterators Iterator} to the first element in each range that - * does not match.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to - * as many elements of this sequence as those in the range [first1, last1). - * - * @return A {@link Pair}, where its members {@link Pair.first first} and {@link Pair.second second} point to the - * first element in both sequences that did not compare equal to each other. If the elements compared in - * both sequences have all matched, the function returns a {@link Pair} with {@link Pair.first first} set - * to last1 and {@link Pair.second second} set to the element in that same relative position in the - * second sequence. If none matched, it returns {@link make_pair}(first1, first2). - */ - function mismatch, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2): Pair; - /** - *

Return first position where two ranges differ.

- * - *

Compares the elements in the range [first1, last1) with those in the range beginning at - * first2, and returns the first element of both sequences that does not match.

- * - *

The function returns a {@link Pair} of {@link iterators Iterator} to the first element in each range that - * does not match.

- * - * @param first1 An {@link Iterator} to the initial position of the first sequence. - * @param last1 An {@link Iterator} to the final position in a sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 An {@link Iterator} to the initial position of the second sequence. The comparison includes up to - * as many elements of this sequence as those in the range [first1, last1). - * @param pred Binary function that accepts two elements as argument (one of each of the two sequences, in the same - * order), and returns a value convertible to bool. The value returned indicates whether - * the elements are considered to match in the context of this function. - * - * @return A {@link Pair}, where its members {@link Pair.first first} and {@link Pair.second second} point to the - * first element in both sequences that did not compare equal to each other. If the elements compared in - * both sequences have all matched, the function returns a {@link Pair} with {@link Pair.first first} set - * to last1 and {@link Pair.second second} set to the element in that same relative position in the - * second sequence. If none matched, it returns {@link make_pair}(first1, first2). - */ - function mismatch, Iterator2 extends Iterator>(first1: Iterator1, last1: Iterator1, first2: Iterator2, compare: (x: T, y: T) => boolean): Pair; - /** - *

Count appearances of value in range.

- * - *

Returns the number of elements in the range [first, last) that compare equal to val.

- * - *

The function uses {@link equal_to} to compare the individual elements to val.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param val Value to match. - * - * @return The number of elements in the range [first, last) that compare equal to val. - */ - function count>(first: InputIterator, last: InputIterator, val: T): number; - /** - *

Return number of elements in range satisfying condition.

- * - *

Returns the number of elements in the range [first, last) for which pred is true. - *

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible - * to bool. The value returned indicates whether the element is counted by this function. - * The function shall not modify its argument. This can either be a function pointer or a function - * object. - */ - function count_if>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): number; - /** - *

Copy range of elements.

- * - *

Copies the elements in the range [first, last) into the range beginning at result.

- * - *

The function returns an iterator to the end of the destination range (which points to the element following the - * last element copied).

- * - *

The ranges shall not overlap in such a way that result points to an element in the range - * [first, last). For such cases, see {@link copy_backward}.

- * - * @param first {@link Iterator Input iterator} to the initial position in a sequence to be copied. - * @param last {@link Iterator Input iterator} to the initial position in a sequence to be copied. 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. - * @param result {@link Iterator Output iterator} to the initial position in the destination sequence. This shall not - * point to any element in the range [first, last). - * - * @return An iterator to the end of the destination range where elements have been copied. - */ - function copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator): OutputIterator; - /** - *

Copy elements.

- * - *

Copies the first n elements from the range beginning at first into the range beginning at - * result.

- * - *

The function returns an iterator to the end of the destination range (which points to one past the last element - * copied).

- * - *

If n is negative, the function does nothing.

- * - *

If the ranges overlap, some of the elements in the range pointed by result may have undefined but valid values. - *

- * - * @param first {@link Iterator Input iterator} to the initial position in a sequence of at least n elements to - * be copied. InputIterator shall point to a type assignable to the elements pointed by - * OutputIterator. - * @param n Number of elements to copy. If this value is negative, the function does nothing. - * @param result {@link Iterator Output iterator} to the initial position in the destination sequence of at least - * n elements. This shall not point to any element in the range [first, last]. - * - * @return An iterator to the end of the destination range where elements have been copied. - */ - function copy_n, OutputIterator extends Iterator>(first: InputIterator, n: number, result: OutputIterator): OutputIterator; - /** - *

Copy certain elements of range.

- * - *

Copies the elements in the range [first, last) for which pred returns true to the - * range beginning at result.

- * - * @param first {@link Iterator Input iterator} to the initial position in a sequence to be copied. - * @param last {@link Iterator Input iterator} to the initial position in a sequence to be copied. 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. - * @param result {@link Iterator Output iterator} to the initial position in the destination sequence. This shall not - * point to any element in the range [first, last). - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element is to be copied (if - * true, it is copied). The function shall not modify any of its arguments. - * - * @return An iterator to the end of the destination range where elements have been copied. - */ - function copy_if, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (x: T) => boolean): OutputIterator; - /** - *

Copy range of elements backward.

- * - *

Copies the elements in the range [first, last) starting from the end into the range terminating - * at result.

- * - *

The function returns an iterator to the first element in the destination range.

- * - *

The resulting range has the elements in the exact same order as [first, last). To reverse their - * order, see {@link reverse_copy}.

- * - *

The function begins by copying *(last-1) into *(result-1), and then follows backward - * by the elements preceding these, until first is reached (and including it).

- * - *

The ranges shall not overlap in such a way that result (which is the past-the-end element in the - * destination range) points to an element in the range (first,last]. For such cases, see {@link copy}.

- * - * @param first {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. - * @param last {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. 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. - * @param result {@link Iterator Bidirectional iterator} to the initial position in the destination sequence. This - * shall not point to any element in the range [first, last). - * - * @return An iterator to the first element of the destination sequence where elements have been copied. - */ - function copy_backward, BidirectionalIterator2 extends Iterator>(first: BidirectionalIterator1, last: BidirectionalIterator1, result: BidirectionalIterator2): BidirectionalIterator2; - /** - *

Fill range with value.

- * - *

Assigns val to all the elements in the range [first, last).

- * - * @param first {@link Iterator Forward iterator} to the initial position in a sequence of elements that support being - * assigned a value of type T. - * @param last {@link Iterator Forward iterator} to the final position in a sequence of elements that support being - * assigned a value of type T.. The range filled 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. - * @param val Value to assign to the elements in the filled range. - */ - function fill>(first: ForwardIterator, last: ForwardIterator, val: T): void; - /** - *

Fill sequence with value.

- * - *

Assigns val to the first n elements of the sequence pointed by first.

- * - * @param first {@link Iterator Output iterator} to the initial position in a sequence of elements that support being - * assigned a value of type T. - * @param n Number of elements to fill. If negative, the function does nothing. - * @param val Value to be used to fill the range. - * - * @return An iterator pointing to the element that follows the last element filled. - */ - function fill_n>(first: OutputIterator, n: number, val: T): OutputIterator; - /** - *

Transform range.

- * - *

Applies op to each of the elements in the range [first, last) and stores the value returned - * by each operation in the range that begins at result.

- * - * @param first {@link Iterator Input iterator} to the initial position in a sequence to be transformed. - * @param last {@link Iterator Input iterator} to the initial position in a sequence to be transformed. 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. - * @param result {@link Iterator Output} iterator to the initial position of the range where the operation results are - * stored. The range includes as many elements as [first, last). - * @param op Unary function that accepts one element of the type pointed to by InputIterator as argument, and - * returns some result value convertible to the type pointed to by OutputIterator. - * - * @return An iterator pointing to the element that follows the last element written in the result sequence. - */ - function transform, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, op: (val: T) => T): OutputIterator; - /** - *

Transform range.

- * - *

Calls binary_op using each of the elements in the range [first1, last1) as first argument, - * and the respective argument in the range that begins at first2 as second argument. The value returned by - * each call is stored in the range that begins at result.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second range. The range includes as - * many elements as [first1, last1). - * @param result {@link Iterator Output} iterator to the initial position of the range where the operation results are - * stored. The range includes as many elements as [first1, last1). - * @param binary_op Binary function that accepts two elements as argument (one of each of the two sequences), and - * returns some result value convertible to the type pointed to by OutputIterator. - * - * @return An iterator pointing to the element that follows the last element written in the result sequence. - */ - function transform, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, result: OutputIterator, binary_op: (x: T, y: T) => T): OutputIterator; - /** - *

Generate values for range with function.

- * - *

Assigns the value returned by successive calls to gen to the elements in the range [first, last). - *

- * - * @param first {@link Iterator Forward iterator} to the initial position in a sequence. - * @param last {@link Iterator Forward iterator} to the final position in a sequence. The range affected 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. - * @param gen Generator function that is called with no arguments and returns some value of a type convertible to - * those pointed by the iterators. - */ - function generate>(first: ForwardIterator, last: ForwardIterator, gen: () => T): void; - /** - *

Generate values for sequence with function.

- * - *

Assigns the value returned by successive calls to gen to the first n elements of the sequence - * pointed by first.

- * - * @param first {@link Iterator Output iterator} to the initial position in a sequence of at least n elements - * that support being assigned a value of the type returned by gen. - * @param n Number of values to generate. If negative, the function does nothing. - * @param gen Generator function that is called with no arguments and returns some value of a type convertible to - * those pointed by the iterators. - * - * @return An iterator pointing to the element that follows the last element whose value has been generated. - */ - function generate_n>(first: ForwardIterator, n: number, gen: () => T): ForwardIterator; - /** - *

Remove consecutive duplicates in range.

- * - *

Removes all but the first element from every consecutive group of equivalent elements in the range - * [first, last).

- * - *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot - * alter the size of an array or a container): The removal is done by replacing the duplicate elements by the next - * element that is not a duplicate, and signaling the new size of the shortened range by returning an iterator to - * the element that should be considered its new past-the-last element.

- * - *

The relative order of the elements not removed is preserved, while the elements between the returned - * iterator and last are left in a valid but unspecified state.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * - * @return An iterator to the element that follows the last element not removed. The range between first and - * this iterator includes all the elements in the sequence that were not considered duplicates. - */ - function unique>(first: InputIterator, last: InputIterator): InputIterator; - /** - *

Remove consecutive duplicates in range.

- * - *

Removes all but the first element from every consecutive group of equivalent elements in the range - * [first, last).

- * - *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot - * alter the size of an array or a container): The removal is done by replacing the duplicate elements by the next - * element that is not a duplicate, and signaling the new size of the shortened range by returning an iterator to - * the element that should be considered its new past-the-last element.

- * - *

The relative order of the elements not removed is preserved, while the elements between the returned - * iterator and last are left in a valid but unspecified state.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Binary function that accepts two elements in the range as argument, and returns a value convertible - * to bool. The value returned indicates whether both arguments are considered equivalent - * (if true, they are equivalent and one of them is removed). The function shall not modify - * any of its arguments. - * - * @return An iterator to the element that follows the last element not removed. The range between first and - * this iterator includes all the elements in the sequence that were not considered duplicates. - */ - function unique>(first: InputIterator, last: InputIterator, pred: (left: t, right: t) => boolean): InputIterator; - /** - *

Copy range removing duplicates.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, except - * consecutive duplicates (elements that compare equal to the element preceding).

- * - *

Only the first element from every consecutive group of equivalent elements in the range - * [first, last) is copied.

- * - *

The comparison between elements is performed by applying {@lnk equal_to}.

- * - * @param first {@link Iterator Forward iterator} to the initial position in a sequence. - * @param last {@link Iterator Forward iterator} 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. - * @param result Output iterator to the initial position of the range where the resulting range of values is stored. - * The pointed type shall support being assigned the value of an element in the range - * [first, last). - * - * @return An iterator pointing to the end of the copied range, which contains no consecutive duplicates. - */ - function unique_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator): OutputIterator; - /** - *

Copy range removing duplicates.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, except - * consecutive duplicates (elements that compare equal to the element preceding).

- * - *

Only the first element from every consecutive group of equivalent elements in the range - * [first, last) is copied.

- * - *

The comparison between elements is performed by applying pred.

- * - * @param first {@link Iterator Forward iterator} to the initial position in a sequence. - * @param last {@link Iterator Forward iterator} 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. - * @param result Output iterator to the initial position of the range where the resulting range of values is stored. - * The pointed type shall support being assigned the value of an element in the range - * [first, last). - * @param pred Binary function that accepts two elements in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether both arguments are considered equivalent (if - * true, they are equivalent and one of them is removed). The function shall not modify any - * of its arguments. - * - * @return An iterator pointing to the end of the copied range, which contains no consecutive duplicates. - */ - function unique_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (x: T, y: T) => boolean): OutputIterator; - /** - *

Remove value from range.

- * - *

Transforms the range [first, last) into a range with all the elements that compare equal to - * val removed, and returns an iterator to the new last of that range.

- * - *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot alter - * the size of an array or a container): The removal is done by replacing the elements that compare equal to - * val by the next element that does not, and signaling the new size of the shortened range by returning an - * iterator to the element that should be considered its new past-the-last element.

- * - *

The relative order of the elements not removed is preserved, while the elements between the returned iterator - * and last are left in a valid but unspecified state.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param val Value to be removed. - */ - function remove>(first: InputIterator, last: InputIterator, val: T): InputIterator; - /** - *

Remove elements from range.

- * - *

Transforms the range [first, last) into a range with all the elements for which pred returns - * true removed, and returns an iterator to the new last of that range.

- * - *

The function cannot alter the properties of the object containing the range of elements (i.e., it cannot - * alter the size of an array or a container): The removal is done by replacing the elements for which pred returns - * true by the next element for which it does not, and signaling the new size of the shortened range - * by returning an iterator to the element that should be considered its new past-the-last element.

- * - *

The relative order of the elements not removed is preserved, while the elements between the returned - * iterator and last are left in a valid but unspecified state.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element is to be removed (if - * true, it is removed). The function shall not modify its argument. - */ - function remove_if>(first: InputIterator, last: InputIterator, pred: (left: T) => boolean): InputIterator; - /** - *

Copy range removing value.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, except - * those elements that compare equal to val.

- * - *

The resulting range is shorter than [first, last) by as many elements as matches in the sequence, - * which are "removed".

- * - *

The function uses {@link equal_to} to compare the individual elements to val.

- * - * @param first {@link Iterator InputIterator} to the initial position in a sequence. - * @param last {@link Iterator InputIterator} 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. - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element in the range - * [first, last). - * @param val Value to be removed. - * - * @return An iterator pointing to the end of the copied range, which includes all the elements in - * [first, last) except those that compare equal to val. - */ - function remove_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, val: T): OutputIterator; - /** - *

Copy range removing values.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, except - * those elements for which pred returns true.

- * - *

The resulting range is shorter than [first, last) by as many elements as matches, which are - * "removed".

- * - * @param first {@link Iterator InputIterator} to the initial position in a sequence. - * @param last {@link Iterator InputIterator} 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. - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element in the range - * [first, last). - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element is to be removed from the copy (if - * true, it is not copied). The function shall not modify its argument. - * - * @return An iterator pointing to the end of the copied range, which includes all the elements in - * [first, last) except those for which pred returns true. - */ - function remove_copy_if, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (val: T) => boolean): OutputIterator; - /** - *

Replace value in range.

- * - *

Assigns new_val to all the elements in the range [first, last) that compare equal to - * old_val.

- * - *

The function uses {@link equal_to} to compare the individual elements to old_val.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param old_val Value to be replaced. - * @param new_val Replacement value. - */ - function replace>(first: InputIterator, last: InputIterator, old_val: T, new_val: T): void; - /** - *

Replace value in range.

- * - *

Assigns new_val to all the elements in the range [first, last) for which pred returns - * true.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element is to be replaced (if - * true, it is replaced). The function shall not modify its argument. - * @param new_val Value to assign to replaced elements. - */ - function replace_if>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean, new_val: T): void; - /** - *

Copy range replacing value.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, replacing - * the appearances of old_value by new_value.

- * - *

The function uses {@link std.equal_to} to compare the individual elements to old_value.

- * - *

The ranges shall not overlap in such a way that result points to an element in the range - * [first, last).

- * - * @param first {@link Iterator InputIterator} to the initial position in a sequence. - * @param last {@link Iterator InputIterator} 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. - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element in the range - * [first, last). - * @param old_val Value to be replaced. - * @param new_val Replacement value. - * - * @return An iterator pointing to the element that follows the last element written in the result sequence. - */ - function replace_copy, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, old_val: T, new_val: T): OutputIterator; - /** - *

Copy range replacing value.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, replacing - * those for which pred returns true by new_value.

- * - * @param first {@link Iterator InputIterator} to the initial position in a sequence. - * @param last {@link Iterator InputIterator} 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. - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element in the range - * [first, last). - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element is to be removed from the copy (if - * true, it is not copied). The function shall not modify its argument. - * @param new_val Value to assign to replaced values. - * - * @return An iterator pointing to the element that follows the last element written in the result sequence. - */ - function replace_copy_if, OutputIterator extends Iterator>(first: InputIterator, last: InputIterator, result: OutputIterator, pred: (val: T) => boolean, new_val: T): OutputIterator; - /** - *

Exchange values of objects pointed to by two iterators.

- * - *

Swaps the elements pointed to by x and y.

- * - *

The function calls {@link Iterator.swap} to exchange the elements.

- * - * @param x {@link Iterator Forward iterator} to the objects to swap. - * @param y {@link Iterator Forward iterator} to the objects to swap. - */ - function iter_swap(x: Iterator, y: Iterator): void; - /** - *

Exchange values of two ranges.

- * - *

Exchanges the values of each of the elements in the range [first1, last1) with those of their - * respective elements in the range beginning at first2.

- * - *

The function calls {@link Iterator.swap} to exchange the elements.

- * - * @param first1 {@link Iterator Forward iterator} to the initial position of the first sequence. - * @param last1 {@link Iterator Forward iterator} to the final position of the first sequence. The range used is - * [first1, last1), including the element pointed by first1, but not the element - * pointed by last1. - * @param first2 {@link Iterator Forward iterator} to the initial position of the second range. The range includes as - * many elements as [first1, last1). The two ranges shall not overlap. - * - * @return An iterator to the last element swapped in the second sequence. - */ - function swap_ranges, ForwardIterator2 extends Iterator>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2): ForwardIterator2; - /** - *

Reverse range.

- * - *

Reverses the order of the elements in the range [first, last).

- * - *

The function calls {@link iter_swap} to swap the elements to their new locations.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - */ - function reverse>(first: InputIterator, last: InputIterator): void; - /** - *

Copy range reversed.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, but in - * reverse order.

- * - * @param first {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. - * @param last {@link Iterator Bidirectional iterator} to the initial position in a sequence to be copied. 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. - * @param result {@link Iterator Output iterator} to the initial position of the range where the reserved range is - * stored. The pointed type shall support being assigned the value of an element in the range - * [first, last). - * - * @return An output iterator pointing to the end of the copied range, which contains the same elements in reverse - * order. - */ - function reverse_copy, OutputIterator extends Iterator>(first: BidirectionalIterator, last: BidirectionalIterator, result: OutputIterator): OutputIterator; - /** - *

Rotate left the elements in range.

- * - *

Rotates the order of the elements in the range [first, last), in such a way that the element - * pointed by middle becomes the new first element.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param middle An {@link Iterator} pointing to the element within the range [first, last) that is - * moved to the first position in the range. - * @param last An {@link Iterator} 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. - * - * @return An iterator pointing to the element that now contains the value previously pointed by first. - */ - function rotate>(first: InputIterator, middle: InputIterator, last: InputIterator): InputIterator; - /** - *

Copy range rotated left.

- * - *

Copies the elements in the range [first, last) to the range beginning at result, but - * rotating the order of the elements in such a way that the element pointed by middle becomes the first - * element in the resulting range.

- * - * @param first {@link Iterator Forward iterator} to the initial position of the range to be copy-rotated. - * @param middle Forward iterator pointing to the element within the range [first, last) that is copied as the first element in the resulting range. - * @param last {@link Iterator Forward iterator} to the final positions of the range to be copy-rotated. 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. - * Notice that in this function, these are not consecutive parameters, but the first and third ones. - * @param result {@link Iterator Output iterator} to the initial position of the range where the reserved range is - * stored. The pointed type shall support being assigned the value of an element in the range - * [first, last). - * - * @return An output iterator pointing to the end of the copied range. - */ - function rotate_copy, OutputIterator extends Iterator>(first: ForwardIterator, middle: ForwardIterator, last: ForwardIterator, result: OutputIterator): OutputIterator; - /** - *

Randomly rearrange elements in range.

- * - *

Rearranges the elements in the range [first, last) randomly.

- * - *

The function swaps the value of each element with that of some other randomly picked element. When provided, - * the function gen determines which element is picked in every case. Otherwise, the function uses some unspecified - * source of randomness.

- * - *

To specify a uniform random generator, see {@link shuffle}.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - */ - function random_shuffle>(first: RandomAccessIterator, last: RandomAccessIterator): void; - /** - *

Randomly rearrange elements in range using generator.

- * - *

Rearranges the elements in the range [first, last) randomly, using g as uniform random - * number generator.

- * - *

The function swaps the value of each element with that of some other randomly picked element. The function - * determines the element picked by calling g().

- * - *

To shuffle the elements of the range without such a generator, see {@link random_shuffle} instead.

- * - *
Note
- *

Using random generator engine is not implemented yet.

- * - * @param first An {@link Iterator} to the initial position in a sequence. - * @param last An {@link Iterator} 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. - */ - function shuffle>(first: RandomAccessIterator, last: RandomAccessIterator): void; - /** - *

Sort elements in range.

- * - *

Sorts the elements in the range [first, last) into ascending order. The elements are compared - * using {@link less}.

- * - * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be sorted. - * 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 - * first. {@link IArrayIterator RandomAccessIterator} shall point to a type for which - * {@link Iterator.swap swap} is properly defined. - * - * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. - * 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which - * {@link Iterator.swap swap} is properly defined. - */ - function sort>(first: RandomAccessIterator, last: RandomAccessIterator): void; - /** - *

Sort elements in range.

- * - *

Sorts the elements in the range [first, last) into specific order. The elements are compared - * using compare.

- * - * @param first {@link IArrayIterator Random-access iterator} to the initial position of the sequence to be sorted. - * 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 - * first. {@link IArrayIterator RandomAccessIterator} shall point to a type for which - * {@link Iterator.swap swap} is properly defined. - * - * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. - * 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. {@link IArrayIterator RandomAccessIterator} shall point to a type for which - * {@link Iterator.swap swap} is properly defined. - * - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value - * convertible to boolean. The value returned indicates whether the element passed as first - * argument is considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. This can either be a function pointer or a function - * object. - */ - function sort>(first: RandomAccessIterator, last: RandomAccessIterator, compare: (left: T, right: T) => boolean): void; - /** - *

Partially sort elements in range.

- * - *

Rearranges the elements in the range [first, last), in such a way that the elements before - * middle are the smallest elements in the entire range and are sorted in ascending order, while the remaining - * elements are left without any specific order.

- * - *

The elements are compared using {@link less}.

- * - * @param last {@link IArrayIterator Random-access iterator} to the first position of the sequence to be sorted. - * @param middle {@link IArrayIterator Random-access iterator} pointing to the element within the range [first, last) that is used as the upper boundary of the elements that are fully sorted. - * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. - * 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. - */ - function partial_sort>(first: RandomAccessIterator, middle: RandomAccessIterator, last: RandomAccessIterator): void; - /** - *

Partially sort elements in range.

- * - *

Rearranges the elements in the range [first, last), in such a way that the elements before - * middle are the smallest elements in the entire range and are sorted in ascending order, while the remaining - * elements are left without any specific order.

- * - *

The elements are compared using comp.

- * - * @param last {@link IArrayIterator Random-access iterator} to the first position of the sequence to be sorted. - * @param middle {@link IArrayIterator Random-access iterator} pointing to the element within the range [first, last) that is used as the upper boundary of the elements that are fully sorted. - * @param last {@link IArrayIterator Random-access iterator} to the final position of the sequence to be sorted. - * 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value - * convertible to boolean. The value returned indicates whether the element passed as - * first argument is considered to go before the second in the specific strict weak ordering it - * defines. The function shall not modify any of its arguments. - */ - function partial_sort>(first: RandomAccessIterator, middle: RandomAccessIterator, last: RandomAccessIterator, compare: (x: T, y: T) => boolean): void; - /** - *

Copy and partially sort range.

- * - *

Copies the smallest elements in the range [first, last) to - * [result_first, result_last), sorting the elements copied. The number of elements copied is the same - * as the {@link distance} between result_first and result_last (unless this is more than the amount of - * elements in [first, last)).

- * - *

The range [first, last) is not modified.

- * - *

The elements are compared using {@link less}.

- * - * @param first {@link Iterator Input iterator} to the initial position of the sequence to copy from. - * @param last {@link Iterator Input iterator} to the final position of the sequence to copy from. 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. - * InputIterator shall point to a type assignable to the elements pointed by - * RandomAccessIterator. - * @param result_first {@link Iterator Random-access iterator} to the initial position of the destination sequence. - * @param result_last {@link Iterator Random-access iterator} to the final position of the destination sequence. - * The range used is [result_first, result_last). - * @param compare Binary function that accepts two elements in the result range as arguments, and returns a value - * convertible to bool. The value returned indicates whether the element passed as first - * argument is considered to go before the second in the specific strict weak ordering it - * defines. The function shall not modify any of its arguments. - * - * @return An iterator pointing to the element that follows the last element written in the result sequence. - */ - function partial_sort_copy, RandomAccessIterator extends Iterator>(first: InputIterator, last: InputIterator, result_first: RandomAccessIterator, result_last: RandomAccessIterator): RandomAccessIterator; - /** - *

Copy and partially sort range.

- * - *

Copies the smallest (or largest) elements in the range [first, last) to - * [result_first, result_last), sorting the elements copied. The number of elements copied is the same - * as the {@link distance} between result_first and result_last (unless this is more than the amount of - * elements in [first, last)).

- * - *

The range [first, last) is not modified.

- * - *

The elements are compared using compare.

- * - * @param first {@link Iterator Input iterator} to the initial position of the sequence to copy from. - * @param last {@link Iterator Input iterator} to the final position of the sequence to copy from. 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. - * InputIterator shall point to a type assignable to the elements pointed by - * RandomAccessIterator. - * @param result_first {@link Iterator Random-access iterator} to the initial position of the destination sequence. - * @param result_last {@link Iterator Random-access iterator} to the final position of the destination sequence. - * The range used is [result_first, result_last). - * @param compare Binary function that accepts two elements in the result range as arguments, and returns a value - * convertible to bool. The value returned indicates whether the element passed as first - * argument is considered to go before the second in the specific strict weak ordering it - * defines. The function shall not modify any of its arguments. - * - * @return An iterator pointing to the element that follows the last element written in the result sequence. - */ - function partial_sort_copy, RandomAccessIterator extends Iterator>(first: InputIterator, last: InputIterator, result_first: RandomAccessIterator, result_last: RandomAccessIterator, compare: (x: T, y: T) => boolean): RandomAccessIterator; - /** - *

Check whether range is sorted.

- * - *

Returns true if the range [first, last) is sorted into ascending order.

- * - *

The elements are compared using {@link less}.

- * - * @param first {@link Iterator Forward iterator} to the initial position of the sequence. - * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. - * - * @return true if the range [first, last) is sorted into ascending order, - * false otherwise. If the range [first, last) contains less than two elements, - * the function always returns true. - */ - function is_sorted>(first: ForwardIterator, last: ForwardIterator): boolean; - /** - *

Check whether range is sorted.

- * - *

Returns true if the range [first, last) is sorted into ascending order.

- * - *

The elements are compared using compare.

- * - * @param first {@link Iterator Forward iterator} to the initial position of the sequence. - * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible - * to bool. The value returned indicates whether the element passed as first argument is - * considered to go before the second in the specific strict weak ordering it defines. The function - * shall not modify any of its arguments. - * - * @return true if the range [first, last) is sorted into ascending order, - * false otherwise. If the range [first, last) contains less than two elements, - * the function always returns true. - */ - function is_sorted>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): boolean; - /** - *

Find first unsorted element in range.

- * - *

Returns an iterator to the first element in the range [first, last) which does not follow an - * ascending order.

- * - *

The range between first and the iterator returned {@link is_sorted is sorted}.

- * - *

If the entire range is sorted, the function returns last.

- * - *

The elements are compared using {@link equal_to}.

- * - * @param first {@link Iterator Forward iterator} to the initial position of the sequence. - * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible - * to bool. The value returned indicates whether the element passed as first argument is - * considered to go before the second in the specific strict weak ordering it defines. The function - * shall not modify any of its arguments. - * - * @return An iterator to the first element in the range which does not follow an ascending order, or last if - * all elements are sorted or if the range contains less than two elements. - */ - function is_sorted_until>(first: ForwardIterator, last: ForwardIterator): ForwardIterator; - /** - *

Find first unsorted element in range.

- * - *

Returns an iterator to the first element in the range [first, last) which does not follow an - * ascending order.

- * - *

The range between first and the iterator returned {@link is_sorted is sorted}.

- * - *

If the entire range is sorted, the function returns last.

- * - *

The elements are compared using compare.

- * - * @param first {@link Iterator Forward iterator} to the initial position of the sequence. - * @param last {@link Iterator Forward iterator} to the final position of the sequence. The range checked 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible - * to bool. The value returned indicates whether the element passed as first argument is - * considered to go before the second in the specific strict weak ordering it defines. The function - * shall not modify any of its arguments. - * - * @return An iterator to the first element in the range which does not follow an ascending order, or last if - * all elements are sorted or if the range contains less than two elements. - */ - function is_sorted_until>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): ForwardIterator; - /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the range [first, last) which does not - * compare less than val.

- * - *

The elements are compared using {@link less}. The elements in the range shall already be {@link is_sorted sorted} - * according to this same criterion ({@link less}), or at least {@link is_partitioned partitioned} with respect to - * val.

- * - *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted - * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

- * - *

Unlike {@link upper_bound}, the value pointed by the iterator returned by this function may also be equivalent - * to val, and not only greater.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared - * with elements of the range [first, last) as the left-hand side operand of {@link less}. - * - * @return An iterator to the lower bound of val in the range. If all the element in the range compare less than - * val, the function returns last. - */ - function lower_bound>(first: ForwardIterator, last: ForwardIterator, val: T): ForwardIterator; - /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the range [first, last) which does not - * compare less than val.

- * - *

The elements are compared using compare. The elements in the range shall already be - * {@link is_sorted sorted} according to this same criterion (compare), or at least - * {@link is_partitioned partitioned} with respect to val.

- * - *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted - * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

- * - *

Unlike {@link upper_bound}, the value pointed by the iterator returned by this function may also be equivalent - * to val, and not only greater.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. - * @param compare Binary function that accepts two arguments (the first of the type pointed by ForwardIterator, - * and the second, always val), and returns a value convertible to bool. The value - * returned indicates whether the first argument is considered to go before the second. The function - * shall not modify any of its arguments. - * - * @return An iterator to the lower bound of val in the range. If all the element in the range compare less than - * val, the function returns last. - */ - function lower_bound>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): ForwardIterator; - /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the range [first, last) which compares - * greater than val.

- * - *

The elements are compared using {@link less}. The elements in the range shall already be {@link is_sorted sorted} - * according to this same criterion ({@link less}), or at least {@link is_partitioned partitioned} with respect to - * val.

- * - *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted - * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

- * - *

Unlike {@link lower_bound}, the value pointed by the iterator returned by this function cannot be equivalent to - * val, only greater.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared - * with elements of the range [first, last) as the left-hand side operand of {@link less}. - * - * @return An iterator to the upper bound of val in the range. If no element in the range comparse greater than - * val, the function returns last. - */ - function upper_bound>(first: ForwardIterator, last: ForwardIterator, val: T): ForwardIterator; - /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the range [first, last) which compares - * greater than val.

- * - *

The elements are compared using compare. The elements in the range shall already be - * {@link is_sorted sorted} according to this same criterion (compare), or at least - * {@link is_partitioned partitioned} with respect to val.

- * - *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted - * range, which is specially efficient for {@link IArrayIterator random-access iterators}.

- * - *

Unlike {@link lower_bound}, the value pointed by the iterator returned by this function cannot be equivalent to - * val, only greater.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. - * @param compare Binary function that accepts two arguments (the first of the type pointed by ForwardIterator, - * and the second, always val), and returns a value convertible to bool. The value - * returned indicates whether the first argument is considered to go before the second. The function - * shall not modify any of its arguments. - * - * @return An iterator to the upper bound of val in the range. If no element in the range comparse greater than - * val, the function returns last. - */ - function upper_bound>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): ForwardIterator; - /** - *

Get subrange of equal elements.

- * - *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with - * values equivalent to val.

- * - *

The elements are compared using {@link less}. Two elements, ax/i> and y are considered equivalent - * if (!std.less(x, y) && !std.less(y, x)).

- * - *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion - * ({@link less}), or at least {@link is_partitioned partitioned} with respect to val.

- * - *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both - * iterators pointing to the nearest value greater than val, if any, or to last, if val compares - * greater than all the elements in the range.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared - * with elements of the range [first, last) as the left-hand side operand of {@link less}. - * - * @return A {@link Pair} object, whose member {@link Pair.first} is an iterator to the lower bound of the subrange of - * equivalent values, and {@link Pair.second} its upper bound. The values are the same as those that would be - * returned by functions {@link lower_bound} and {@link upper_bound} respectively. - */ - function equal_range>(first: ForwardIterator, last: ForwardIterator, val: T): Pair; - /** - *

Get subrange of equal elements.

- * - *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with - * values equivalent to val.

- * - *

The elements are compared using compare. Two elements, ax/i> and y are considered equivalent - * if (!compare(x, y) && !compare(y, x)).

- * - *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion - * (compare), or at least {@link is_partitioned partitioned} with respect to val.

- * - *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both - * iterators pointing to the nearest value greater than val, if any, or to last, if val compares - * greater than all the elements in the range.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. - * @param compare Binary function that accepts two arguments of the type pointed by ForwardIterator (and of type - * T), and returns a value convertible to bool. The value returned indicates whether - * the first argument is considered to go before the second. The function shall not modify any of its - * arguments. - * - * @return A {@link Pair} object, whose member {@link Pair.first} is an iterator to the lower bound of the subrange of - * equivalent values, and {@link Pair.second} its upper bound. The values are the same as those that would be - * returned by functions {@link lower_bound} and {@link upper_bound} respectively. - */ - function equal_range>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): Pair; - /** - *

Get subrange of equal elements.

- * - *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with - * values equivalent to val.

- * - *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent - * if (!std.less(x, y) && !std.less(y, x)).

- * - *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion - * ({@link less}), or at least {@link is_partitioned partitioned} with respect to val.

- * - *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both - * iterators pointing to the nearest value greater than val, if any, or to last, if val compares - * greater than all the elements in the range.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. T shall be a type supporting being compared - * with elements of the range [first, last) as the left-hand side operand of {@link less}. - * - * @return true if an element equivalent to val is found, and false otherwise. - */ - function binary_search>(first: ForwardIterator, last: ForwardIterator, val: T): boolean; - /** - *

Get subrange of equal elements.

- * - *

Returns the bounds of the subrange that includes all the elements of the range [first, last) with - * values equivalent to val.

- * - *

The elements are compared using {compare}. Two elements, x and y are considered equivalent - * if (!compare(x, y) && !compare(y, x)).

- * - *

The elements in the range shall already be {@link is_sorted sorted} according to this same criterion - * (compare), or at least {@link is_partitioned partitioned} with respect to val.

- * - *

If val is not equivalent to any value in the range, the subrange returned has a length of zero, with both - * iterators pointing to the nearest value greater than val, if any, or to last, if val compares - * greater than all the elements in the range.

- * - * @param first {@link Iterator Forward iterator} to the initial position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) sequence. - * @param last {@link Iterator Forward iterator} to the final position of a {@link is_sorted sorted} (or properly - * {@link is_partitioned partitioned}) 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. - * @param val Value of the lower bound to search for in the range. - * @param compare Binary function that accepts two arguments of the type pointed by ForwardIterator (and of type - * T), and returns a value convertible to bool. The value returned indicates whether - * the first argument is considered to go before the second. The function shall not modify any of its - * arguments. - * - * @return true if an element equivalent to val is found, and false otherwise. - */ - function binary_search>(first: ForwardIterator, last: ForwardIterator, val: T, compare: (x: T, y: T) => boolean): boolean; - /** - *

Test whether range is partitioned.

- * - *

Returns true if all the elements in the range [first, last) for which pred - * returns true precede those for which it returns false.

- * - *

If the range is {@link IContainer.empty empty}, the function returns true.

- * - * @param first {@link Iterator Input iterator} to the initial position of the sequence. - * @param last {@link Iterator Input iterator} to the final position of the 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. - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element belongs to the first group (if - * true, the element is expected before all the elements for which it returns - * false). The function shall not modify its argument. - * - * @return true if all the elements in the range [first, last) for which pred returns - * true precede those for which it returns false. Otherwise it returns - * false. If the range is {@link IContainer.empty empty}, the function returns true. - */ - function is_partitioned>(first: InputIterator, last: InputIterator, pred: (x: T) => boolean): boolean; - /** - *

Partition range in two.

- * - *

Rearranges the elements from the range [first, last), in such a way that all the elements for - * which pred returns true precede all those for which it returns false. The iterator - * returned points to the first element of the second group.

- * - *

The relative ordering within each group is not necessarily the same as before the call. See - * {@link stable_partition} for a function with a similar behavior but with stable ordering within each group.

- * - * @param first {@link Iterator Forward iterator} to the initial position of the sequence to partition. - * @param last {@link Iterator Forward iterator} to the final position of the sequence to partition. 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. - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element belongs to the first group (if - * true, the element is expected before all the elements for which it returns - * false). The function shall not modify its argument. - * - * @return An iterator that points to the first element of the second group of elements (those for which pred - * returns false), or last if this group is {@link IContainer.empty empty}. - */ - function partition>(first: BidirectionalIterator, last: BidirectionalIterator, pred: (x: T) => boolean): BidirectionalIterator; - /** - *

Partition range in two - stable ordering.

- * - *

Rearranges the elements in the range [first, last), in such a way that all the elements for which - * pred returns true precede all those for which it returns false, and, unlike - * function {@link partition}, the relative order of elements within each group is preserved.

- * - *

This is generally implemented using an internal temporary buffer.

- * - * @param first {@link Iterator Bidirectional iterator} to the initial position of the sequence to partition. - * @param last {@link Iterator Bidirectional iterator} to the final position of the sequence to partition. 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. - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element belongs to the first group (if - * true, the element is expected before all the elements for which it returns - * false). The function shall not modify its argument. - * - * @return An iterator that points to the first element of the second group of elements (those for which pred - * returns false), or last if this group is {@link IContainer.empty empty}. - */ - function stable_partition>(first: BidirectionalIterator, last: BidirectionalIterator, pred: (x: T) => boolean): BidirectionalIterator; - /** - *

Partition range into two.

- * - *

Copies the elements in the range [first, last) for which pred returns true - * into the range pointed by result_true, and those for which it does not into the range pointed by - * result_false.

- * - * @param first {@link Iterator Input iterator} to the initial position of the range to be copy-partitioned. - * @param last {@link Iterator Input iterator} to the final position of the range to be copy-partitioned. 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. - * @param result_true {@link Iterator Output iterator} to the initial position of the range where the elements for - * which pred returns true are stored. - * @param result_false {@link Iterator Output iterator} to the initial position of the range where the elements for - * which pred returns false are stored. - * @param pred Unary function that accepts an element pointed by InputIterator as argument, and returns a value - * convertible to bool. The value returned indicates on which result range the element is - * copied. The function shall not modify its argument. - * - * @return A {@link Pair} of iterators with the end of the generated sequences pointed by result_true and - * result_false, respectivelly. Its member {@link Pair.first first} points to the element that follows - * the last element copied to the sequence of elements for which pred returned true. Its - * member {@link Pair.second second} points to the element that follows the last element copied to the sequence - * of elements for which pred returned false. - */ - function partition_copy, OutputIterator1 extends Iterator, OutputIterator2 extends Iterator>(first: InputIterator, last: InputIterator, result_true: OutputIterator1, result_false: OutputIterator2, pred: (val: T) => T): Pair; - /** - *

Get partition point.

- * - *

Returns an iterator to the first element in the partitioned range [first, last) for which - * pred is not true, indicating its partition point.

- * - *

The elements in the range shall already {@link is_partitioned be partitioned}, as if {@link partition} had been - * called with the same arguments.

- * - *

The function optimizes the number of comparisons performed by comparing non-consecutive elements of the sorted - * range, which is specially efficient for {@link Iteartor random-access iterators}.

- * - * @param first {@link Iterator Forward iterator} to the initial position of the partitioned sequence. - * @param last {@link Iterator Forward iterator} to the final position of the partitioned sequence. The range checked - * is [first, last), which contains all the elements between first an last, - * including the element pointed by first but not the element pointed by last. - * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible to - * bool. The value returned indicates whether the element goes before the partition point (if - * true, it goes before; if false goes at or after it). The function shall not - * modify its argument. - * - * @return An iterator to the first element in the partitioned range [first, last) for which pred - * is not true, or last if it is not true for any element. - */ - function partition_point>(first: ForwardIterator, last: ForwardIterator, pred: (x: T) => boolean): ForwardIterator; - /** - *

Merge sorted ranges.

- * - *

Combines the elements in the sorted ranges [first1, last1) and [first2, last2), into - * a new range beginning at result with all its elements sorted.

- * - *

The elements are compared using {@link less}. The elements in both ranges shall already be ordered according to - * this same criterion ({@link less}). The resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting combined - * range is stored. Its size is equal to the sum of both ranges above. - * - * @return An iterator pointing to the past-the-end element in the resulting sequence. - */ - function merge, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; - /** - *

Merge sorted ranges.

- * - *

Combines the elements in the sorted ranges [first1, last1) and [first2, last2), into - * a new range beginning at result with all its elements sorted.

- * - *

The elements are compared using {@link less}. The elements in both ranges shall already be ordered according to - * this same criterion (compare). The resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting combined - * range is stored. Its size is equal to the sum of both ranges above. - * @param compare Binary function that accepts two arguments of the types pointed by the iterators, and returns a value - * convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. - * - * @return An iterator pointing to the past-the-end element in the resulting sequence. - */ - function merge, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; - /** - *

Merge consecutive sorted ranges.

- * - *

Merges two consecutive sorted ranges: [first, middle) and [middle, last), putting - * the result into the combined sorted range [first, last).

- * - *

The elements are compared using {@link less}. The elements in both ranges shall already be ordered according to - * this same criterion ({@link less}). The resulting range is also sorted according to this.

- * - *

The function preserves the relative order of elements with equivalent values, with the elements in the first - * range preceding those equivalent in the second.

- * - * @param first {@link Iterator Bidirectional iterator} to the initial position in the first sorted sequence to merge. - * This is also the initial position where the resulting merged range is stored. - * @param middle {@link Iterator Bidirectional iterator} to the initial position of the second sorted sequence, which - * because both sequences must be consecutive, matches the past-the-end position of the first - * sequence. - * @param last {@link Iterator Bidirectional iterator} to the past-the-end position of the second sorted - * sequence. This is also the past-the-end position of the range where the resulting merged range is - * stored. - */ - function inplace_merge>(first: BidirectionalIterator, middle: BidirectionalIterator, last: BidirectionalIterator): void; - /** - *

Merge consecutive sorted ranges.

- * - *

Merges two consecutive sorted ranges: [first, middle) and [middle, last), putting - * the result into the combined sorted range [first, last).

- * - *

The elements are compared using compare. The elements in both ranges shall already be ordered according - * to this same criterion (compare). The resulting range is also sorted according to this.

- * - *

The function preserves the relative order of elements with equivalent values, with the elements in the first - * range preceding those equivalent in the second.

- * - * @param first {@link Iterator Bidirectional iterator} to the initial position in the first sorted sequence to merge. - * This is also the initial position where the resulting merged range is stored. - * @param middle {@link Iterator Bidirectional iterator} to the initial position of the second sorted sequence, which - * because both sequences must be consecutive, matches the past-the-end position of the first - * sequence. - * @param last {@link Iterator Bidirectional iterator} to the past-the-end position of the second sorted - * sequence. This is also the past-the-end position of the range where the resulting merged range is - * stored. - * @param compare Binary function that accepts two arguments of the types pointed by the iterators, and returns a value - * convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. - */ - function inplace_merge>(first: BidirectionalIterator, middle: BidirectionalIterator, last: BidirectionalIterator, compare: (x: T, y: T) => boolean): void; - /** - *

Test whether sorted range includes another sorted range.

- * - *

Returns true if the sorted range [first1, last1) contains all the elements in the - * sorted range [first2, last2).

- * - *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent - * if (!std.less(x, y) && !std.less(y, x)).

- * - *

The elements in the range shall already be ordered according to this same criterion ({@link less}).

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence (which is tested on - * whether it contains the second sequence). The range used is [first1, last1), which - * contains all the elements between first1 and last1, including the element pointed by - * first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. (which is tested - * on whether it is contained in the first sequence). The range used is [first2, last2). - * - * @return true if every element in the range [first2, last2) is contained in the range - * [first1, last1), false otherwise. If [first2, last2) is an empty - * range, the function returns true. - */ - function includes, InputIterator2 extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2): boolean; - /** - *

Test whether sorted range includes another sorted range.

- * - *

Returns true if the sorted range [first1, last1) contains all the elements in the - * sorted range [first2, last2).

- * - *

The elements are compared using compare. Two elements, x and y are considered equivalent - * if (!compare(x, y) && !compare(y, x)).

- * - *

The elements in the range shall already be ordered according to this same criterion (compare).

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence (which is tested on - * whether it contains the second sequence). The range used is [first1, last1), which - * contains all the elements between first1 and last1, including the element pointed by - * first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. (which is tested - * on whether it is contained in the first sequence). The range used is [first2, last2). - * @param compare Binary function that accepts two elements as arguments (one from each of the two sequences, in the - * same order), and returns a value convertible to bool. The value returned indicates - * whether the element passed as first argument is considered to go before the second in the specific - * strict weak ordering it defines. The function shall not modify any of its arguments. - * - * @return true if every element in the range [first2, last2) is contained in the range - * [first1, last1), false otherwise. If [first2, last2) is an empty - * range, the function returns true. - */ - function includes, InputIterator2 extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, compare: (x: T, y: T) => boolean): boolean; - /** - *

Union of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by result with the set union of the - * two sorted ranges [first1, last1) and [first2, last2).

- * - *

The union of two sets is formed by the elements that are present in either one of the sets, or in both. - * Elements from the second range that have an equivalent element in the first range are not copied to the resulting - * range.

- * - *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent - * if (!std.less(x, y) && !std.less(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion ({@link less}). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the other ranges. - * - * @return An iterator to the end of the constructed range. - */ - function set_union, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; - /** - *

Union of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by result with the set union of the - * two sorted ranges [first1, last1) and [first2, last2).

- * - *

The union of two sets is formed by the elements that are present in either one of the sets, or in both. - * Elements from the second range that have an equivalent element in the first range are not copied to the resulting - * range.

- * - *

The elements are compared using compare. Two elements, x and y are considered equivalent - * if (!compare(x, y) && !compare(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion (compare). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the other ranges. - * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a - * value convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. - * - * @return An iterator to the end of the constructed range. - */ - function set_union, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; - /** - *

Intersection of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by result with the set intersection of - * the two sorted ranges [first1, last1) and [first2, last2).

- * - *

The intersection of two sets is formed only by the elements that are present in both sets. The elements - * copied by the function come always from the first range, in the same order.

- * - *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent - * if (!std.less(x, y) && !std.less(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion ({@link less}). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the first range. - * - * @return An iterator to the end of the constructed range. - */ - function set_intersection, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; - /** - *

Intersection of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by result with the set intersection of - * the two sorted ranges [first1, last1) and [first2, last2).

- * - *

The intersection of two sets is formed only by the elements that are present in both sets. The elements - * copied by the function come always from the first range, in the same order.

- * - *

The elements are compared using compare. Two elements, x and y are considered equivalent - * if (!compare(x, y) && !compare(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion (compare). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the first range. - * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a - * value convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. - * - * @return An iterator to the end of the constructed range. - */ - function set_intersection, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; - /** - *

Difference of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by result with the set difference of - * the sorted range [first1, last1) with respect to the sorted range [first2, last2).

- * - *

The difference of two sets is formed by the elements that are present in the first set, but not in the - * second one. The elements copied by the function come always from the first range, in the same order.

- * - *

For containers supporting multiple occurrences of a value, the difference includes as many occurrences of - * a given value as in the first range, minus the amount of matching elements in the second, preserving order.

- * - *

Notice that this is a directional operation - for a symmetrical equivalent, see {@link set_symmetric_difference}. - *

- * - *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent - * if (!std.less(x, y) && !std.less(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion ({@link less}). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the first range. - * - * @return An iterator to the end of the constructed range. - */ - function set_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; - /** - *

Difference of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by result with the set difference of - * the sorted range [first1, last1) with respect to the sorted range [first2, last2).

- * - *

The difference of two sets is formed by the elements that are present in the first set, but not in the - * second one. The elements copied by the function come always from the first range, in the same order.

- * - *

For containers supporting multiple occurrences of a value, the difference includes as many occurrences of - * a given value as in the first range, minus the amount of matching elements in the second, preserving order.

- * - *

Notice that this is a directional operation - for a symmetrical equivalent, see {@link set_symmetric_difference}. - *

- * - *

The elements are compared using compare. Two elements, x and y are considered equivalent - * if (!compare(x, y) && !compare(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion (compare). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the first range. - * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a - * value convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. - * - * @return An iterator to the end of the constructed range. - */ - function set_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; - /** - *

Symmetric difference of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by0 result with the set - * symmetric difference of the two sorted ranges [first1, last1) and [first2, last2). - *

- * - *

The symmetric difference of two sets is formed by the elements that are present in one of the sets, but - * not in the other. Among the equivalent elements in each range, those discarded are those that appear before in the - * existent order before the call. The existing order is also preserved for the copied elements.

- * - *

The elements are compared using {@link less}. Two elements, x and y are considered equivalent - * if (!std.less(x, y) && !std.less(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion ({@link std.less}). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the other ranges. - * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a - * value convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. - * - * @return An iterator to the end of the constructed range. - */ - function set_symmetric_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator): OutputIterator; - /** - *

Symmetric difference of two sorted ranges.

- * - *

Constructs a sorted range beginning in the location pointed by0 result with the set - * symmetric difference of the two sorted ranges [first1, last1) and [first2, last2). - *

- * - *

The symmetric difference of two sets is formed by the elements that are present in one of the sets, but - * not in the other. Among the equivalent elements in each range, those discarded are those that appear before in the - * existent order before the call. The existing order is also preserved for the copied elements.

- * - *

The elements are compared using compare. Two elements, x and y are considered equivalent - * if (!compare(x, y) && !compare(y, x)).

- * - *

The elements in the ranges shall already be ordered according to this same criterion (compare). The - * resulting range is also sorted according to this.

- * - * @param first1 {@link Iterator Input iterator} to the initial position of the first sorted sequence. - * @param last1 {@link Iterator Input iterator} to the final position of the first sorted sequence. The range used is - * [first1, last1), which contains all the elements between first1 and last1, - * including the element pointed by first1 but not the element pointed by last1. - * @param first2 {@link Iterator Input iterator} to the initial position of the second sorted sequence. - * @param last2 {@link Iterator Input iterator} to the final position of the second sorted sequence. The range used is - * [first2, last2). - * @param result {@link Iterator Output iterator} to the initial position of the range where the resulting sequence is - * stored. The pointed type shall support being assigned the value of an element from the other ranges. - * @param compare Binary function that accepts two arguments of the types pointed by the input iterators, and returns a - * value convertible to bool. The value returned indicates whether the first argument is - * considered to go before the second in the specific strict weak ordering it defines. The - * function shall not modify any of its arguments. - * - * @return An iterator to the end of the constructed range. - */ - function set_symmetric_difference, InputIterator2 extends Iterator, OutputIterator extends Iterator>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, last2: InputIterator2, result: OutputIterator, compare: (x: T, y: T) => boolean): OutputIterator; - /** - *

Return the smallest.

- * - *

Returns the smallest of all the elements in the args.

- * - * @param args Values to compare. - * - * @return The lesser of the values passed as arguments. - */ - function min(...args: T[]): T; - /** - *

Return the largest.

- * - *

Returns the largest of all the elements in the args.

- * - * @param args Values to compare. - * - * @return The largest of the values passed as arguments. - */ - function max(...args: T[]): T; - /** - *

Return smallest and largest elements.

- * - *

Returns a {@link Pair} with the smallest of all the elements in the args as first element (the first of - * them, if there are more than one), and the largest as second (the last of them, if there are more than one).

- * - * @param args Values to compare. - * - * @return The lesser and greatest of the values passed as arguments. - */ - function minmax(...args: T[]): Pair; - /** - *

Return smallest element in range.

- * - *

Returns an iterator pointing to the element with the smallest value in the range [first, last). - *

- * - *

The comparisons are performed using either {@link less}; An element is the smallest if no other element - * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first - * of such elements.

- * - * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. - * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. - * - * @return An iterator to smallest value in the range, or last if the range is empty. - */ - function min_element>(first: ForwardIterator, last: ForwardIterator): ForwardIterator; - /** - *

Return smallest element in range.

- * - *

Returns an iterator pointing to the element with the smallest value in the range [first, last). - *

- * - *

The comparisons are performed using either compare; An element is the smallest if no other element - * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first - * of such elements.

- * - * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. - * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible - * to bool. The value returned indicates whether the element passed as first argument is - * considered less than the second. The function shall not modify any of its arguments. - * - * @return An iterator to smallest value in the range, or last if the range is empty. - */ - function min_element>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): ForwardIterator; - /** - *

Return largest element in range.

- * - *

Returns an iterator pointing to the element with the largest value in the range [first, last). - *

- * - *

The comparisons are performed using either {@link greater}; An element is the largest if no other element - * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first - * of such elements.

- * - * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. - * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. - * - * @return An iterator to largest value in the range, or last if the range is empty. - */ - function max_element>(first: ForwardIterator, last: ForwardIterator): ForwardIterator; - /** - *

Return largest element in range.

- * - *

Returns an iterator pointing to the element with the largest value in the range [first, last). - *

- * - *

The comparisons are performed using either compare; An element is the largest if no other element - * compares less than it. If more than one element fulfills this condition, the iterator returned points to the first - * of such elements.

- * - * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. - * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible - * to bool. The value returned indicates whether the element passed as first argument is - * considered less than the second. The function shall not modify any of its arguments. - * - * @return An iterator to largest value in the range, or last if the range is empty. - */ - function max_element>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): ForwardIterator; - /** - *

Return smallest and largest elements in range.

- * - *

Returns a {@link Pair} with an iterator pointing to the element with the smallest value in the range - * [first, last) as first element, and the largest as second.

- * - *

The comparisons are performed using either {@link less} and {@link greater}.

- * - *

If more than one equivalent element has the smallest value, the first iterator points to the first of such - * elements.

- * - *

If more than one equivalent element has the largest value, the second iterator points to the last of such - * elements.

- * - * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. - * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible - * to bool. The value returned indicates whether the element passed as first argument is - * considered less than the second. The function shall not modify any of its arguments. - * - * @return A {@link Pair} with an iterator pointing to the element with the smallest value in the range - * [first, last) as first element, and the largest as second. - */ - function minmax_element>(first: ForwardIterator, last: ForwardIterator): Pair; - /** - *

Return smallest and largest elements in range.

- * - *

Returns a {@link Pair} with an iterator pointing to the element with the smallest value in the range - * [first, last) as first element, and the largest as second.

- * - *

The comparisons are performed using either compare.

- * - *

If more than one equivalent element has the smallest value, the first iterator points to the first of such - * elements.

- * - *

If more than one equivalent element has the largest value, the second iterator points to the last of such - * elements.

- * - * @param first {@link Iteartor Input iterator} to the initial final position of the sequence to compare. - * @param last {@link Iteartor Input iterator} to the final final position of the sequence to compare. 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. - * @param compare Binary function that accepts two elements in the range as arguments, and returns a value convertible - * to bool. The value returned indicates whether the element passed as first argument is - * considered less than the second. The function shall not modify any of its arguments. - * - * @return A {@link Pair} with an iterator pointing to the element with the smallest value in the range - * [first, last) as first element, and the largest as second. - */ - function minmax_element>(first: ForwardIterator, last: ForwardIterator, compare: (x: T, y: T) => boolean): Pair; -} -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. - * - * @param obj - */ - function hash(obj: any): 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; - /** - *

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). - *
  • + *
  • empty
  • + *
  • size
  • + *
  • front
  • + *
  • back
  • + *
  • push_back
  • + *
  • pop_back
  • *
* - *

Calling the returned object returns the same type as fn.

+ *

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 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.

+ * @param Type of elements. * - *

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.

- * - *

This namespace declares an unspecified number of objects: _1, _2, _3, ..., which are - * used to specify placeholders in calls to function {@link std.bind}.

- * - *

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/ + * @reference http://www.cplusplus.com/reference/stack/stack * @author Jeongho Nam */ - namespace placeholders { + class Stack { /** - * @hidden + * The underlying object for implementing the LIFO */ - 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 { - /** - *

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 { - /** - * A message representing specification about the Exception. - */ - protected message: string; + private container_; /** * Default Constructor. */ constructor(); /** - *

Construct from a message.

- * - * @param message A message representing specification about the Exception. + * Copy Constructor. */ - constructor(what: string); + constructor(stack: Stack); /** - *

Get string identifying exception.

- *

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

+ *

Return size.

* - *

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.

+ *

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}. */ - what(): 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 { + size(): number; /** - *

Construct from a message.

+ *

Test whether container is empty.

* - * @param message A message representing specification about the Exception. + *

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.

*/ - constructor(what: 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 { + empty(): boolean; /** - *

Construct from a message.

+ *

Access next element.

* - * @param message A message representing specification about the Exception. + *

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}. */ - constructor(what: 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 { + top(): T; /** - *

Construct from a message.

+ *

Insert element.

* - * @param message A message representing specification about the Exception. + *

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. */ - constructor(what: 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 { + push(val: T): void; /** - *

Construct from a message.

+ *

Remove top element.

* - * @param message A message representing specification about the Exception. + *

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.

*/ - constructor(what: 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 { + pop(): void; /** - *

Construct from a message.

+ *

Swap contents.

* - * @param message A message representing specification about the Exception. - */ - constructor(what: 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.

+ *

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

* - * @param message A message representing specification about the Exception. - */ - constructor(what: 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/outflow_error - * @author Jeongho Nam - */ - class OverflowError extends RuntimeError { - /** - *

Construct from a message.

+ *

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

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

*/ - constructor(what: 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(what: 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(what: string); + swap(obj: Stack): void; } } declare namespace std.base { @@ -8246,6 +8121,8 @@ declare namespace std { */ code(): ErrorCode; } +} +declare namespace std { /** *

Error category.

* @@ -8367,6 +8244,8 @@ declare namespace std { */ equivalent(code: ErrorCode, val_cond: number): boolean; } +} +declare namespace std { /** *

Error condition.

* @@ -8402,6 +8281,8 @@ declare namespace std { */ constructor(val: number, category: ErrorCategory); } +} +declare namespace std { /** *

Error code.

* @@ -8433,7 +8314,896 @@ declare namespace std { constructor(val: number, category: ErrorCategory); } } +declare namespace std.base { + /** + *

Common interface for tree-structured map.

+ * + *

{@link ITreeMap ITreeMaps} are associative containers that store elements formed by a combination of + * a key value and a mapped value, following a specific order.

+ * + *

In a {@link ITreeMap}, 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 ITreeMap}are always sorted by its key following a + * strict weak ordering criterion indicated by its internal comparison method (of {@link less}).

+ * + *

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

+ * + *

{@link ITreeMap TreeMultiMaps} 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.
+ *
+ * + * @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 + * @author Jeongho Nam + */ + interface ITreeMap { + /** + *

Return iterator to lower bound.

+ * + *

Returns an iterator pointing to the first element in the container whose key is not considered to + * go before k (i.e., either it is equivalent or goes after).

+ * + *

The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(k, element_key) would return false.

+ * + *

If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element whose key is not less than k

. + * + *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except + * in the case that the {@link ITreeMap} contains an element with a key equivalent to k: In this + * case, {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} + * returns an iterator pointing to the next element.

+ * + * @param k Key to search for. + * + * @return An iterator to the the first element in the container whose key is not considered to go before + * k, or {@link ITreeMap.end} if all keys are considered to go before k. + */ + lower_bound(key: Key): MapIterator; + /** + *

Return iterator to upper bound.

+ * + *

Returns an iterator pointing to the first element in the container whose key is considered to + * go after k

. + * + *

The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(k, element_key) would return true.

+ * + *

If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element whose key is greater than k

. + * + *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except + * in the case that the map contains an element with a key equivalent to k: In this case + * {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} returns an + * iterator pointing to the next element.

+ * + * @param k Key to search for. + * + * @return An iterator to the the first element in the container whose key is considered to go after + * k, or {@link TreeMap.end end} if no keys are considered to go after k. + */ + upper_bound(key: Key): MapIterator; + /** + *

Get range of equal elements.

+ * + *

Returns the bounds of a range that includes all the elements in the container which have a key + * equivalent to k

. + * + *

If no matches are found, the range returned has a length of zero, with both iterators pointing to + * the first element that has a key considered to go after k according to the container's internal + * comparison object (key_comp).

+ * + *

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

+ * + * @param k Key to search for. + * + * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of + * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound + * (the same as {@link upper_bound}). + */ + equal_range(key: Key): Pair, MapIterator>; + } +} 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 { + /** + * RB-Tree+ object for implemeting the {@link TreeMap}. + */ + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (left: Key, right: 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: (left: Key, right: 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: (left: Key, right: Key) => boolean); + /** + * Copy Constructor. + * + * @param container Another map to copy. + */ + constructor(container: base.MapContainer); + /** + * Copy Constructor. + * + * @param container Another map to copy. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: base.MapContainer, compare: (left: Key, right: 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: (left: Key, right: Key) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: Key): MapIterator; + /** + * @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; + /** + * @inheritdoc + */ + swap(obj: base.UniqueMap): void; + /** + * @hidden + */ + private swap_tree_map(obj); + } +} +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.

+ * + *

+ * + *

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 { + private tree_; + /** + * Default Constructor. + */ + constructor(); + /** + * Construct from compare. + * + * @param compare A binary predicate determines order of elements. + */ + constructor(compare: (left: Key, right: 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: (left: Key, right: 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: (left: Key, right: Key) => boolean); + /** + * Copy Constructor. + * + * @param container Another map to copy. + */ + constructor(container: base.MapContainer); + /** + * Copy Constructor. + * + * @param container Another map to copy. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: base.MapContainer, compare: (left: Key, right: 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: (left: Key, right: Key) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(key: Key): MapIterator; + /** + * @inheritdoc + */ + count(key: Key): number; + /** + * @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; + /** + * @inheritdoc + */ + swap(obj: base.MultiMap): void; + /** + * @hidden + */ + private swap_tree_multimap(obj); + } +} +declare namespace std.base { + /** + *

A common interface for tree-structured set.

+ * + *

{@link ITreeSet TreeMultiSets} are containers that store elements following a specific order.

+ * + *

In a {@link ITreeSet}, 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 ITreeSet} 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 ITreeSet TreeMultiSets} are always sorted following a strict + * weak ordering criterion indicated by its internal comparison method (of {@link IComparable.less less}).

+ * + *

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

+ * + *

{@link ITreeSet 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.
+ *
+ * + * @param Type of the elements. Each element in a {@link ITreeSet} container is also identified + * by this value (each value is itself also the element's key). + * + * @reference http://www.cplusplus.com/reference/set + * @author Jeongho Nam + */ + interface ITreeSet { + /** + *

Return iterator to lower bound.

+ * + *

Returns an iterator pointing to the first element in the container which is not considered to + * go before val (i.e., either it is equivalent or goes after).

+ * + *

The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(element,val) would return false.

+ * + *

If the {@link ITreeSet} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element that is not less than val.

+ + *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except + * in the case that the {@link ITreeSet} contains elements equivalent to val: In this case + * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas + * {@link upper_bound} returns an iterator pointing to the element following the last.

+ * + * @param val Value to compare. + * + * @return An iterator to the the first element in the container which is not considered to go before + * val, or {@link ITreeSet.end} if all elements are considered to go before val. + */ + lower_bound(val: T): SetIterator; + /** + *

Return iterator to upper bound.

+ * + *

Returns an iterator pointing to the first element in the container which is considered to go after + * val.

+ + *

The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(val,element) would return true.

+ + *

If the {@code ITreeSet} class is instantiated with the default comparison type (less), the + * function returns an iterator to the first element that is greater than val.

+ * + *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except + * in the case that the {@ITreeSet} contains elements equivalent to val: In this case + * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas + * {@link upper_bound} returns an iterator pointing to the element following the last.

+ * + * @param val Value to compare. + * + * @return An iterator to the the first element in the container which is considered to go after + * val, or {@link TreeSet.end end} if no elements are considered to go after val. + */ + upper_bound(val: T): SetIterator; + /** + *

Get range of equal elements.

+ * + *

Returns the bounds of a range that includes all the elements in the container that are equivalent + * to val.

+ * + *

If no matches are found, the range returned has a length of zero, with both iterators pointing to + * the first element that is considered to go after val according to the container's + * internal comparison object (key_comp).

+ * + *

Two elements of a multiset 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).

+ * + * @param key Value to search for. + * + * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of + * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound + * (the same as {@link upper_bound}). + */ + equal_range(val: T): Pair, SetIterator>; + } +} +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 { + /** + * RB-Tree+ object for implemeting the {@link TreeSet}. + */ + private tree_; + /** + * 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); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(val: T): SetIterator; + /** + * @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; + /** + * @inheritdoc + */ + swap(obj: base.UniqueSet): void; + /** + * @hidden + */ + private swap_tree_set(obj); + } +} +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 { + /** + * RB-Tree+ object for implemeting the {@link TreeMultiSet}. + */ + private tree_; + /** + * 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.Container); + /** + * Copy Constructor with compare. + * + * @param container A container to be copied. + * @param compare A binary predicate determines order of elements. + */ + constructor(container: base.Container, 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); + /** + * 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: (left: T, right: T) => boolean); + /** + * @inheritdoc + */ + clear(): void; + /** + * @inheritdoc + */ + find(val: T): SetIterator; + /** + * @inheritdoc + */ + count(val: T): number; + /** + * @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; + /** + * @inheritdoc + */ + swap(obj: base.MultiSet): void; + /** + * @hidden + */ + private swap_tree_set(obj); + } +} +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.

* @@ -8496,8 +9266,518 @@ declare namespace std { */ function make_pair(x: T1, y: T2): Pair; } -declare namespace std.example { - function test_all(): void; +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.IArrayContainer { + /** + * Type definition of {@link Vector}'s {@link VectorIterator iterator}. + */ + static iterator: typeof VectorIterator; + /** + *

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: base.IContainer); + /** + *

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; + /** + * @hiddde + */ + protected erase_by_range(first: VectorIterator, last: VectorIterator): VectorIterator; + /** + * @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. + */ + 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 { + constructor(base: VectorIterator); + /** + * @inheritdoc + */ + protected create_neighbor(): VectorReverseIterator; + /** + * Set value. + */ + value: T; + /** + * Get index. + */ + index: number; + } } declare namespace std.base { /** @@ -9189,18 +10469,17 @@ declare namespace std.base { } } declare namespace std.base { - const MIN_SIZE: number; - const RATIO: number; - const MAX_RATIO: number; - function code(par: any): number; -} -declare namespace std.base { + enum Hash { + MIN_SIZE = 10, + RATIO = 1, + MAX_RATIO = 2, + } /** *

Hask buckets.

* * @author Jeongho Nam */ - abstract class HashBuckets { + class HashBuckets { private buckets_; private item_size_; /** @@ -9208,14 +10487,21 @@ declare namespace std.base { */ constructor(); /** - * Reserve the bucket size. + *

Reconstruction of hash table.

* - * @param size Number of bucket size to reserve. + *

All the elements in the hash buckets are rearranged according to their hash value into the new set of + * buckets. This may alter the order of iteration of elements within the container.

+ * + *

Notice that {@link rehash rehashes} are automatically performed whenever its number of elements is going + * to greater than its own {@link capacity}.

+ * + * @param size Number of bucket size to rehash. */ - reserve(size: number): void; + rehash(size: number): void; clear(): void; size(): number; item_size(): number; + capacity(): number; at(index: number): Vector; hash_index(val: T): number; insert(val: T): void; @@ -9830,6 +11116,9 @@ declare namespace std.base { uncle: XTreeNode; } } +declare namespace std.example { + function test_all(): void; +} declare namespace std.example { function test_bind(): void; } From a969442874d475655313f7c4722d40cd056f9238 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 21 Jun 2016 15:29:04 +0900 Subject: [PATCH 2/4] TypeScript-STL and Samchon-Framework, right sentence --- .../samchon-collection-tests.ts | 5 +- samchon-collection/samchon-collection.d.ts | 22 +- samchon-framework/samchon-framework-tests.ts | 5 +- samchon-framework/samchon-framework.d.ts | 2978 +++++++++------ samchon-library/samchon-library-tests.ts | 5 +- samchon-library/samchon-library.d.ts | 22 +- typescript-stl/typescript-stl-tests.ts | 5 +- typescript-stl/typescript-stl.d.ts | 3369 +++++++++-------- 8 files changed, 3679 insertions(+), 2732 deletions(-) diff --git a/samchon-collection/samchon-collection-tests.ts b/samchon-collection/samchon-collection-tests.ts index 028eb32caa..5744f11a7a 100644 --- a/samchon-collection/samchon-collection-tests.ts +++ b/samchon-collection/samchon-collection-tests.ts @@ -1,7 +1,4 @@ /// -declare var global: any; -declare var require: (name: string) => any; - -collection = require("samchon-collection"); +import collection = require("samchon-collection"); console.log(collection); \ No newline at end of file diff --git a/samchon-collection/samchon-collection.d.ts b/samchon-collection/samchon-collection.d.ts index 3decceb20b..0bff8791f9 100644 --- a/samchon-collection/samchon-collection.d.ts +++ b/samchon-collection/samchon-collection.d.ts @@ -3,21 +3,11 @@ // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// ------------------------------------------------------------------------------------ -// In Samchon Collection, merging multiple 'ts' files to a module is not possible yet. -// Instead of using "import" instruction, use such trick: -// -// -// declare var global: any; -// declare var require: Function; -// -// collection = require("samchon-collection"); -// let cont: collection.ArrayCollection = new collection.ArrayCollection(); -// -// -// Those declaration of global and require can be substituted by using "node.d.ts" -// ------------------------------------------------------------------------------------ - /// -declare var collection: typeof samchon.collection; \ No newline at end of file +declare module "samchon-collection" +{ + import collection = samchon.collection; + export = collection; +} + diff --git a/samchon-framework/samchon-framework-tests.ts b/samchon-framework/samchon-framework-tests.ts index 5820b158c3..88c2632a37 100644 --- a/samchon-framework/samchon-framework-tests.ts +++ b/samchon-framework/samchon-framework-tests.ts @@ -1,7 +1,4 @@ /// -declare var global: any; -declare var require: any; - -global["samchon"] = require("samchon-framework"); +import samchon = require("samchon-framework"); console.log(samchon); \ No newline at end of file diff --git a/samchon-framework/samchon-framework.d.ts b/samchon-framework/samchon-framework.d.ts index 9dd52e9503..5a885d6cd1 100644 --- a/samchon-framework/samchon-framework.d.ts +++ b/samchon-framework/samchon-framework.d.ts @@ -1,25 +1,15 @@ -// Type definitions for Samchon Framework v1.1.0 +// Type definitions for Samchon Framework v1.2.0 // Project: https://github.com/samchon/framework // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// ------------------------------------------------------------------------------------ -// In Samchon Framework, merging multiple 'ts' files to a module is not possible yet. -// Instead of using "import" instruction, use such trick: -// -// -// declare var global: any; -// declare var require: Function; -// -// global["samchon"] = require("samchon-framework"); -// let invoke: samchon.protocol.Invoke = new samchon.protocol.Invoke("setValue", 3); -// -// -// Those declaration of global and require can be substituted by using "node.d.ts" -// ------------------------------------------------------------------------------------ - /// +declare module "samchon-framework" +{ + export = samchon; +} + /** * Samchon Framework, A SDN framework. * @@ -39,6 +29,1015 @@ declare namespace samchon.protocol.master { } declare namespace samchon.protocol.slave { } +declare namespace samchon.collection { + /** + * A {@link Vector} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class ArrayCollection extends std.Vector implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + push(...items: U[]): number; + /** + * @inheritdoc + */ + push_back(val: T): void; + /** + * @hidden + */ + protected insert_by_repeating_val(position: std.VectorIterator, n: number, val: T): std.VectorIterator; + /** + * @hidden + */ + protected insert_by_range>(position: std.VectorIterator, begin: InputIterator, end: InputIterator): std.VectorIterator; + /** + * @inheritdoc + */ + pop_back(): void; + /** + * @hidden + */ + protected erase_by_range(first: std.VectorIterator, last: std.VectorIterator): std.VectorIterator; + /** + * @hidden + */ + private notify_insert(first, last); + /** + * @hidden + */ + private notify_erase(first, last); + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + unshift(...items: U[]): number; + /** + * @inheritdoc + */ + pop(): T; + /** + * @inheritdoc + */ + splice(start: number): T[]; + /** + * @inheritdoc + */ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + } +} +declare namespace samchon.library { + /** + * An event class. + * + *
    + *
  • Comments from - https://developer.mozilla.org/en-US/docs/Web/API/Event/
  • + *
+ * + * @author Jeongho Nam + */ + class BasicEvent implements Event { + NONE: number; + CAPTURING_PHASE: number; + AT_TARGET: number; + BUBBLING_PHASE: number; + private type_; + private target_; + private currentTarget_; + protected trusted_: boolean; + protected bubbles_: boolean; + protected cancelable_: boolean; + protected defaultPrevented_: boolean; + protected cancelBubble_: boolean; + private timeStamp_; + constructor(type: string, bubbles?: boolean, cancelable?: boolean); + /** + * @inheritdoc + */ + initEvent(type: string, bubbles: boolean, cancelable: boolean): void; + /** + * @inheritdoc + */ + preventDefault(): void; + /** + * @inheritdoc + */ + stopImmediatePropagation(): void; + /** + * @inheritdoc + */ + stopPropagation(): void; + /** + * @inheritdoc + */ + type: string; + /** + * @inheritdoc + */ + target: IEventDispatcher; + /** + * @inheritdoc + */ + currentTarget: IEventDispatcher; + /** + * @inheritdoc + */ + isTrusted: boolean; + /** + * @inheritdoc + */ + bubbles: boolean; + /** + * @inheritdoc + */ + cancelable: boolean; + /** + * @inheritdoc + */ + eventPhase: number; + /** + * @inheritdoc + */ + defaultPrevented: boolean; + /** + * @inheritdoc + */ + srcElement: Element; + /** + * @inheritdoc + */ + cancelBubble: boolean; + /** + * @inheritdoc + */ + timeStamp: number; + /** + * Don't know what it is. + */ + returnValue: boolean; + } + class ProgressEvent extends library.BasicEvent { + static PROGRESS: string; + protected numerator_: number; + protected denominator_: number; + constructor(type: string, numerator: number, denominator: number); + numerator: number; + denominator: number; + } +} +declare namespace samchon.collection { + /** + * Type of function pointer for {@link CollectionEvent CollectionEvents}. + */ + interface CollectionEventListener extends EventListener { + (event: CollectionEvent): void; + } + /** + * + */ + class CollectionEvent extends library.BasicEvent { + static INSERT: string; + static ERASE: string; + /** + * + */ + private first_; + /** + * + */ + private last_; + /** + * + * + * @param type + * @param first + * @param last + */ + constructor(type: string, first: std.Iterator, last: std.Iterator); + /** + * + */ + container: ICollection; + /** + * + */ + first: std.Iterator; + /** + * + */ + last: std.Iterator; + } +} +declare namespace samchon.collection { + /** + * A {@link Deque} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class DequeCollection extends std.Deque implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + push(...items: U[]): number; + /** + * @inheritdoc + */ + push_back(val: T): void; + /** + * @hidden + */ + protected insert_by_repeating_val(position: std.DequeIterator, n: number, val: T): std.DequeIterator; + /** + * @hidden + */ + protected insert_by_range>(position: std.DequeIterator, begin: InputIterator, end: InputIterator): std.DequeIterator; + /** + * @inheritdoc + */ + pop_back(): void; + /** + * @hidden + */ + protected erase_by_range(first: std.DequeIterator, last: std.DequeIterator): std.DequeIterator; + /** + * @hidden + */ + private notify_insert(first, last); + /** + * @hidden + */ + private notify_erase(first, last); + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link HashMap} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class HashMapCollection extends std.HashMap implements ICollection> { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } + /** + * A {@link HashMultiMap} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class HashMultiMapCollection extends std.HashMap implements ICollection> { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link HashSet} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class HashSetCollection extends std.TreeSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + protected handle_insert(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } + class HashMultiSetCollection extends std.TreeMultiSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * An interface for {@link IContainer containers} who can detect element I/O events. + * + * @author Jeongho Nam + */ + interface ICollection extends std.base.IContainer, library.IEventDispatcher { + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + *

Registers an event listener object with an EventDispatcher object so that the listener + * receives notification of an event. You can register event listeners on all nodes in the display + * list for a specific type of event, phase, and priority. + * + *

After you successfully register an event listener, you cannot change its priority through + * additional calls to addEventListener(). To change a listener's priority, you must first call + * removeEventListener(). Then you can register the listener again with the new priority level.

+ * + *

Keep in mind that after the listener is registered, subsequent calls to addEventListener() + * with a different type or useCapture value result in the creation of a separate listener + * registration. For example, if you first register a listener with useCapture set to true, + * it listens only during the capture phase. If you call addEventListener() again using the same + * listener object, but with useCapture set to false, you have two separate listeners: one that + * listens during the capture phase and another that listens during the target and bubbling phases.

+ * + *

You cannot register an event listener for only the target phase or the bubbling phase. + * Those phases are coupled during registration because bubbling applies only to the ancestors of + * the target node.

+ * + *

If you no longer need an event listener, remove it by calling removeEventListener(), or + * memory problems could result. Event listeners are not automatically removed from memory because + * the garbage collector does not remove the listener as long as the dispatching object exists + * (unless the useWeakReference parameter is set to true).

+ * + *

Copying an EventDispatcher instance does not copy the event listeners attached to it. (If + * your newly created node needs an event listener, you must attach the listener after creating + * the node.) However, if you move an EventDispatcher instance, the event listeners attached to + * it move along with it.

+ * + *

If the event listener is being registered on a node while an event is also being processed + * on this node, the event listener is not triggered during the current phase but may be triggered + * during a later phase in the event flow, such as the bubbling phase.

+ * + *

If an event listener is removed from a node while an event is being processed on the node, + * it is still triggered by the current actions. After it is removed, the event listener is never + * invoked again (unless it is registered again for future processing).

+ * + * @param event The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. + * @param listener The listener function that processes the event. + * This function must accept an Event object as its only parameter and must return + * nothing. + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + *

Registers an event listener object with an EventDispatcher object so that the listener + * receives notification of an event. You can register event listeners on all nodes in the display + * list for a specific type of event, phase, and priority. + * + *

After you successfully register an event listener, you cannot change its priority through + * additional calls to addEventListener(). To change a listener's priority, you must first call + * removeEventListener(). Then you can register the listener again with the new priority level.

+ * + *

Keep in mind that after the listener is registered, subsequent calls to addEventListener() + * with a different type or useCapture value result in the creation of a separate listener + * registration. For example, if you first register a listener with useCapture set to true, + * it listens only during the capture phase. If you call addEventListener() again using the same + * listener object, but with useCapture set to false, you have two separate listeners: one that + * listens during the capture phase and another that listens during the target and bubbling phases.

+ * + *

You cannot register an event listener for only the target phase or the bubbling phase. + * Those phases are coupled during registration because bubbling applies only to the ancestors of + * the target node.

+ * + *

If you no longer need an event listener, remove it by calling removeEventListener(), or + * memory problems could result. Event listeners are not automatically removed from memory because + * the garbage collector does not remove the listener as long as the dispatching object exists + * (unless the useWeakReference parameter is set to true).

+ * + *

Copying an EventDispatcher instance does not copy the event listeners attached to it. (If + * your newly created node needs an event listener, you must attach the listener after creating + * the node.) However, if you move an EventDispatcher instance, the event listeners attached to + * it move along with it.

+ * + *

If the event listener is being registered on a node while an event is also being processed + * on this node, the event listener is not triggered during the current phase but may be triggered + * during a later phase in the event flow, such as the bubbling phase.

+ * + *

If an event listener is removed from a node while an event is being processed on the node, + * it is still triggered by the current actions. After it is removed, the event listener is never + * invoked again (unless it is registered again for future processing).

+ * + * @param event The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. + * @param listener The listener function that processes the event. + * This function must accept an Event object as its only parameter and must return + * nothing. + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * Removes a listener from the EventDispatcher object. If there is no matching listener registered + * with the EventDispatcher object, a call to this method has no effect. + * + * @param type The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. + * @param listener The listener object to remove. + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * Removes a listener from the EventDispatcher object. If there is no matching listener registered + * with the EventDispatcher object, a call to this method has no effect. + * + * @param type The type of event; {@link CollectionEvent.INSERT} or {@link CollectionEvent.ERASE}. + * @param listener The listener object to remove. + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link List} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class ListCollection extends std.List implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + push(...items: T[]): number; + /** + * @inheritdoc + */ + push_front(val: T): void; + /** + * @inheritdoc + */ + push_back(val: T): void; + /** + * @hidden + */ + protected insert_by_repeating_val(position: std.ListIterator, n: number, val: T): std.ListIterator; + /** + * @hidden + */ + protected insert_by_range>(position: std.ListIterator, begin: InputIterator, end: InputIterator): std.ListIterator; + /** + * @inheritdoc + */ + pop_front(): void; + /** + * @inheritdoc + */ + pop_back(): void; + /** + * @hidden + */ + protected erase_by_range(first: std.ListIterator, last: std.ListIterator): std.ListIterator; + /** + * @hidden + */ + private notify_insert(first, last); + /** + * @hidden + */ + private notify_erase(first, last); + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link TreeMap} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class TreeMapCollection extends std.HashMap implements ICollection> { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } + /** + * A {@link TreeMultiMap} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class TreeMultiMapCollection extends std.HashMap implements ICollection> { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } +} +declare namespace samchon.collection { + /** + * A {@link TreeMap} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class TreeSetCollection extends std.TreeSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } + /** + * A {@link TreeMultiSet} who can detect element I/O events. + * + * @author Jeongho Nam + */ + class TreeMultiSetCollection extends std.TreeMultiSet implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ + private event_dispatcher_; + /** + * @inheritdoc + */ + protected handle_insert(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + protected handle_erase(first: std.SetIterator, last: std.SetIterator): void; + /** + * @inheritdoc + */ + hasEventListener(type: string): boolean; + /** + * @inheritdoc + */ + dispatchEvent(event: Event): boolean; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + } +} declare namespace samchon.library { /** *

XML is a class representing a tree structued xml objects.

@@ -151,16 +1150,16 @@ declare namespace samchon.library { /** *

Get value.

*/ - getValue(): any; + getValue(): string; /** - *

Test wheter a property exists or not.

+ *

Test whether a property exists or not.

*/ hasProperty(key: string): boolean; /** *

Get property by its key.

*/ - getProperty(key: string): any; - getPropertyMap(): std.HashMap; + getProperty(key: string): string; + getPropertyMap(): std.HashMap; /** *

Set tag (identifier) of the XML.

*/ @@ -193,11 +1192,11 @@ declare namespace samchon.library { * * @param val A value to set */ - setValue(str: any): void; + setValue(str: string): void; /** *

Set a property with its key.

*/ - setProperty(key: string, value: any): void; + setProperty(key: string, value: string): void; /** *

Erase a property by its key.

* @@ -375,10 +1374,6 @@ declare namespace samchon.library { * @author Jeongho Nam */ class XMLList extends std.Vector { - /** - *

Default Constructor.

- */ - constructor(); getTag(): string; /** *

Convert XMLList to string.

@@ -395,47 +1390,27 @@ declare namespace samchon.library { } } declare namespace samchon.collection { - /** - * A {@link Vector} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class ArrayCollection extends std.Vector implements ICollection { - private insert_handler_; - private erase_handler_; + class XMLListCollection extends library.XMLList implements ICollection { + /** + * A chain object taking responsibility of dispatching events. + */ private event_dispatcher_; /** * @inheritdoc */ - set_insert_handler(listener: CollectionHandler): void; + push(...items: U[]): number; /** * @inheritdoc */ - set_erase_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - get_insert_handler(): CollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): CollectionHandler; - /** - * @inheritdoc - */ - push(...items: U[]): number; - /** - * @inheritdoc - */ - push_back(val: T): void; + push_back(val: library.XML): void; /** * @hidden */ - protected insert_by_repeating_val(position: std.VectorIterator, n: number, val: T): std.VectorIterator; + protected insert_by_repeating_val(position: std.VectorIterator, n: number, val: library.XML): std.VectorIterator; /** * @hidden */ - protected insert_by_range>(position: std.VectorIterator, begin: InputIterator, end: InputIterator): std.VectorIterator; + protected insert_by_range>(position: std.VectorIterator, begin: InputIterator, end: InputIterator): std.VectorIterator; /** * @inheritdoc */ @@ -443,7 +1418,7 @@ declare namespace samchon.collection { /** * @hidden */ - protected erase_by_range(first: std.VectorIterator, last: std.VectorIterator): std.VectorIterator; + protected erase_by_range(first: std.VectorIterator, last: std.VectorIterator): std.VectorIterator; /** * @hidden */ @@ -471,11 +1446,11 @@ declare namespace samchon.collection { /** * @inheritdoc */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; /** * @inheritdoc */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ @@ -487,1020 +1462,34 @@ declare namespace samchon.collection { /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; /** * @inheritdoc */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; + removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; /** * @inheritdoc */ - unshift(...items: U[]): number; + unshift(...items: U[]): number; /** * @inheritdoc */ - pop(): T; + pop(): library.XML; /** * @inheritdoc */ - splice(start: number): T[]; + splice(start: number): library.XML[]; /** * @inheritdoc */ - splice(start: number, deleteCount: number, ...items: T[]): T[]; + splice(start: number, deleteCount: number, ...items: library.XML[]): library.XML[]; } } -declare namespace samchon.protocol { - /** - *

An entity, a standard data class.

- * - *

Entity is a class for standardization of expression method using on network I/O by XML. If - * Invoke is a standard message protocol of Samchon Framework which must be kept, Entity is a - * recommended semi-protocol of message for expressing a data class. Following the semi-protocol - * Entity is not imposed but encouraged.

- * - *

As we could get advantages from standardization of message for network I/O with Invoke, - * we can get additional advantage from standardizing expression method of data class with Entity. - * We do not need to know a part of network communication. Thus, with the Entity, we can only - * concentrate on entity's own logics and relationships between another entities. Entity does not - * need to how network communications are being done.

- * - *

I say repeatedly. Expression method of Entity is recommended, but not imposed. It's a semi - * protocol for network I/O but not a essential protocol must be kept. The expression method of - * Entity, using on network I/O, is expressed by XML string.

- * - *

If your own network system has a critical performance issue on communication data class, - * it would be better to using binary communication (with ByteArray). - * Don't worry about the problem! Invoke also provides methods for binary data (ByteArray).

- * - * @author Jeongho Nam - */ - abstract class Entity implements IEntity { - /** - *

Default Constructor.

- */ - constructor(); - construct(xml: library.XML): void; - key(): any; - abstract TAG(): string; - toXML(): library.XML; - } +declare namespace samchon.example { + function test_file_reference(): void; } -declare namespace samchon.library { - /** - * An event class. - * - *
    - *
  • Comments from - https://developer.mozilla.org/en-US/docs/Web/API/Event/
  • - *
- * - * @author Jeongho Nam - */ - class BasicEvent implements Event { - NONE: number; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; - private type_; - private target_; - private currentTarget_; - protected trusted_: boolean; - protected bubbles_: boolean; - protected cancelable_: boolean; - protected defaultPrevented_: boolean; - protected cancelBubble_: boolean; - private timeStamp_; - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * @inheritdoc - */ - initEvent(type: string, bubbles: boolean, cancelable: boolean): void; - /** - * @inheritdoc - */ - preventDefault(): void; - /** - * @inheritdoc - */ - stopImmediatePropagation(): void; - /** - * @inheritdoc - */ - stopPropagation(): void; - /** - * @inheritdoc - */ - type: string; - /** - * @inheritdoc - */ - target: IEventDispatcher; - /** - * @inheritdoc - */ - currentTarget: IEventDispatcher; - /** - * @inheritdoc - */ - isTrusted: boolean; - /** - * @inheritdoc - */ - bubbles: boolean; - /** - * @inheritdoc - */ - cancelable: boolean; - /** - * @inheritdoc - */ - eventPhase: number; - /** - * @inheritdoc - */ - defaultPrevented: boolean; - /** - * @inheritdoc - */ - srcElement: Element; - /** - * @inheritdoc - */ - cancelBubble: boolean; - /** - * @inheritdoc - */ - timeStamp: number; - /** - * Don't know what it is. - */ - returnValue: boolean; - } - class ProgressEvent extends BasicEvent { - static PROGRESS: string; - protected numerator_: number; - protected denominator_: number; - constructor(type: string, numerator: number, denominator: number); - numerator: number; - denominator: number; - } -} -declare namespace samchon.collection { - interface CollectionEventListener extends EventListener { - (event: CollectionEvent): void; - } - class CollectionEvent extends library.BasicEvent { - static INSERT: string; - static ERASE: string; - private first_; - private last_; - constructor(type: string, first: std.Iterator, last: std.Iterator); - container: ICollection; - first: std.Iterator; - last: std.Iterator; - } -} -declare namespace samchon.collection { - /** - * A {@link Deque} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class DequeCollection extends std.Deque implements ICollection { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - set_insert_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - get_insert_handler(): CollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): CollectionHandler; - /** - * @inheritdoc - */ - push(...items: U[]): number; - /** - * @inheritdoc - */ - push_back(val: T): void; - /** - * @hidden - */ - protected insert_by_repeating_val(position: std.DequeIterator, n: number, val: T): std.DequeIterator; - /** - * @hidden - */ - protected insert_by_range>(position: std.DequeIterator, begin: InputIterator, end: InputIterator): std.DequeIterator; - /** - * @inheritdoc - */ - pop_back(): void; - /** - * @hidden - */ - protected erase_by_range(first: std.DequeIterator, last: std.DequeIterator): std.DequeIterator; - /** - * @hidden - */ - private notify_insert(first, last); - /** - * @hidden - */ - private notify_erase(first, last); - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } -} -declare namespace samchon.collection { - /** - * A {@link HashMap} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class HashMapCollection extends std.HashMap implements ICollection> { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - get_insert_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - set_insert_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } - /** - * A {@link HashMultiMap} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class HashMultiMapCollection extends std.HashMap implements ICollection> { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - get_insert_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - set_insert_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } -} -declare namespace samchon.collection { - /** - * A {@link HashSet} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class HashSetCollection extends std.TreeSet implements ICollection { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - set_insert_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - get_insert_handler(): CollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): CollectionHandler; - /** - * @inheritdoc - */ - protected handle_insert(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } - class HashMultiSetCollection extends std.TreeMultiSet implements ICollection { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - set_insert_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - get_insert_handler(): CollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): CollectionHandler; - /** - * @inheritdoc - */ - protected handle_insert(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } -} -declare namespace samchon.collection { - interface CollectionHandler { - (first: std.Iterator, last: std.Iterator): void; - } - interface MapCollectionHandler extends CollectionHandler> { - (first: std.MapIterator, last: std.MapIterator): void; - } - /** - * An interface for {@link IContainer containers} who can detect element I/O events. - * - * @author Jeongho Nam - */ - interface ICollection extends std.base.IContainer, library.IEventDispatcher { - get_insert_handler(): CollectionHandler; - get_erase_handler(): CollectionHandler; - set_insert_handler(listener: CollectionHandler): any; - set_erase_handler(listener: CollectionHandler): any; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } -} -declare namespace samchon.collection { - /** - * A {@link List} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class ListCollection extends std.List implements ICollection { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - set_insert_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - get_insert_handler(): CollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): CollectionHandler; - /** - * @inheritdoc - */ - push(...items: T[]): number; - /** - * @inheritdoc - */ - push_front(val: T): void; - /** - * @inheritdoc - */ - push_back(val: T): void; - /** - * @hidden - */ - protected insert_by_repeating_val(position: std.ListIterator, n: number, val: T): std.ListIterator; - /** - * @hidden - */ - protected insert_by_range>(position: std.ListIterator, begin: InputIterator, end: InputIterator): std.ListIterator; - /** - * @inheritdoc - */ - pop_front(): void; - /** - * @inheritdoc - */ - pop_back(): void; - /** - * @hidden - */ - protected erase_by_range(first: std.ListIterator, last: std.ListIterator): std.ListIterator; - /** - * @hidden - */ - private notify_insert(first, last); - /** - * @hidden - */ - private notify_erase(first, last); - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } -} -declare namespace samchon.collection { - /** - * A {@link TreeMap} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class TreeMapCollection extends std.HashMap implements ICollection> { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - get_insert_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - set_insert_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } - /** - * A {@link TreeMultiMap} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class TreeMultiMapCollection extends std.HashMap implements ICollection> { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - get_insert_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): MapCollectionHandler; - /** - * @inheritdoc - */ - set_insert_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: MapCollectionHandler): void; - /** - * @inheritdoc - */ - protected handle_insert(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.MapIterator, last: std.MapIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } -} -declare namespace samchon.collection { - /** - * A {@link TreeMap} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class TreeSetCollection extends std.TreeSet implements ICollection { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - set_insert_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - get_insert_handler(): CollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): CollectionHandler; - /** - * @inheritdoc - */ - protected handle_insert(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } - /** - * A {@link TreeMultiSet} who can detect element I/O events. - * - * @author Jeongho Nam - */ - class TreeMultiSetCollection extends std.TreeMultiSet implements ICollection { - private insert_handler_; - private erase_handler_; - private event_dispatcher_; - /** - * @inheritdoc - */ - set_insert_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - set_erase_handler(listener: CollectionHandler): void; - /** - * @inheritdoc - */ - get_insert_handler(): CollectionHandler; - /** - * @inheritdoc - */ - get_erase_handler(): CollectionHandler; - /** - * @inheritdoc - */ - protected handle_insert(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - protected handle_erase(first: std.SetIterator, last: std.SetIterator): void; - /** - * @inheritdoc - */ - hasEventListener(type: string): boolean; - /** - * @inheritdoc - */ - dispatchEvent(event: Event): boolean; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - addEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: string, listener: EventListener, thisArg: Object): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener): void; - /** - * @inheritdoc - */ - removeEventListener(type: "insert" | "erase", listener: CollectionEventListener, thisArg: Object): void; - } +declare namespace samchon.example { + function test_web_client(): void; } declare namespace samchon.library { /** @@ -1568,7 +1557,7 @@ declare namespace samchon.library { /** *

An array using for dividing each element index.

*/ - private dividerArray; + private divider_array; /** *

Construct from size of N and R.

* @@ -1626,11 +1615,7 @@ declare namespace samchon.library { * class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, * and write simple hooks to route calls into the aggregated EventDispatcher.

* - *
    - *
  • Made by AS3 - http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/IEventDispatcher.html - *
- * - * @see EventDispatcher + * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/IEventDispatcher.html * @author Migrated by Jeongho Nam */ interface IEventDispatcher { @@ -1656,7 +1641,51 @@ declare namespace samchon.library { * dispatched, its target property cannot be changed, so you must create a new copy * of the event for redispatching to work. */ - dispatchEvent(event: BasicEvent): boolean; + dispatchEvent(event: library.BasicEvent): boolean; + /** + *

Registers an event listener object with an EventDispatcher object so that the listener + * receives notification of an event. You can register event listeners on all nodes in the display + * list for a specific type of event, phase, and priority. + * + *

After you successfully register an event listener, you cannot change its priority through + * additional calls to addEventListener(). To change a listener's priority, you must first call + * removeEventListener(). Then you can register the listener again with the new priority level.

+ * + *

Keep in mind that after the listener is registered, subsequent calls to addEventListener() + * with a different type or useCapture value result in the creation of a separate listener + * registration. For example, if you first register a listener with useCapture set to true, + * it listens only during the capture phase. If you call addEventListener() again using the same + * listener object, but with useCapture set to false, you have two separate listeners: one that + * listens during the capture phase and another that listens during the target and bubbling phases.

+ * + *

You cannot register an event listener for only the target phase or the bubbling phase. + * Those phases are coupled during registration because bubbling applies only to the ancestors of + * the target node.

+ * + *

If you no longer need an event listener, remove it by calling removeEventListener(), or + * memory problems could result. Event listeners are not automatically removed from memory because + * the garbage collector does not remove the listener as long as the dispatching object exists + * (unless the useWeakReference parameter is set to true).

+ * + *

Copying an EventDispatcher instance does not copy the event listeners attached to it. (If + * your newly created node needs an event listener, you must attach the listener after creating + * the node.) However, if you move an EventDispatcher instance, the event listeners attached to + * it move along with it.

+ * + *

If the event listener is being registered on a node while an event is also being processed + * on this node, the event listener is not triggered during the current phase but may be triggered + * during a later phase in the event flow, such as the bubbling phase.

+ * + *

If an event listener is removed from a node while an event is being processed on the node, + * it is still triggered by the current actions. After it is removed, the event listener is never + * invoked again (unless it is registered again for future processing).

+ * + * @param event The type of event. + * @param listener The listener function that processes the event. + * This function must accept an Event object as its only parameter and must return + * nothing. + */ + addEventListener(type: string, listener: EventListener): void; /** *

Registers an event listener object with an EventDispatcher object so that the listener * receives notification of an event. You can register event listeners on all nodes in the display @@ -1701,6 +1730,14 @@ declare namespace samchon.library { * nothing. */ addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * Removes a listener from the EventDispatcher object. If there is no matching listener registered + * with the EventDispatcher object, a call to this method has no effect. + * + * @param type The type of event. + * @param listener The listener object to remove. + */ + removeEventListener(type: string, listener: EventListener): void; /** * Removes a listener from the EventDispatcher object. If there is no matching listener registered * with the EventDispatcher object, a call to this method has no effect. @@ -1784,11 +1821,264 @@ declare namespace samchon.library { /** * @inheritdoc */ - addEventListener(type: string, listener: EventListener, thisArg?: Object): void; + addEventListener(type: string, listener: EventListener): void; /** * @inheritdoc */ - removeEventListener(type: string, listener: EventListener, thisArg?: Object): void; + addEventListener(type: string, listener: EventListener, thisArg: Object): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener): void; + /** + * @inheritdoc + */ + removeEventListener(type: string, listener: EventListener, thisArg: Object): void; + } +} +declare namespace samchon.library { + /** + *

The {@link FileReference} class provides a means to load and save files in browser level.

+ * + *

The {@link FileReference} class provides a means to {@link load} and {@link save} files in browser level. A + * browser-system dialog box prompts the user to select a file to {@link load} or a location for {@link svae}. Each + * {@link FileReference} object refers to a single file on the user's disk and has properties that contain + * information about the file's size, type, name, creation date, modification date, and creator type (Macintosh only). + *

+ * + *

FileReference instances are created in the following ways:

+ *
    + *
  • + * When you use the new operator with the {@link FileReference} constructor: + * var myFileReference = new FileReference(); + *
  • + *
  • + * When you call the {@link FileReferenceList.browse} method, which creates an array of {@link FileReference} + * objects. + *
  • + *
+ * + *

During a load operation, all the properties of a {@link FileReference} object are populated by calls to the + * {@link FileReference.browse} or {@link FileReferenceList.browse} methods. During a save operation, the name + * property is populated when the select event is dispatched; all other properties are populated when the complete + * event is dispatched.

+ * + *

The {@link browse browse()} method opens an browser-system dialog box that prompts the user to select a file + * for {@link load}. The {@link FileReference.browse} method lets the user select a single file; the + * {@link FileReferenceList.browse} method lets the user select multiple files. After a successful call to the + * {@link browse browse()} method, call the {@link FileReference.load} method to load one file at a time. The + * {@link FileReference.save} method prompts the user for a location to save the file and initiates downloading from + * a binary or string data.

+ * + *

The {@link FileReference} and {@link FileReferenceList} classes do not let you set the default file location + * for the dialog box that the {@link browse} or {@link save} methods generate. The default location shown in the + * dialog box is the most recently browsed folder, if that location can be determined, or the desktop. The classes do + * not allow you to read from or write to the transferred file. They do not allow the browser that initiated the + * {@link load} or {@link save} to access the loaded or saved file or the file's location on the user's disk.

+ * + * @references http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html + * @author Jeongho Nam + */ + class FileReference extends EventDispatcher { + /** + * @hidden + */ + private file_; + /** + * @hidden + */ + private data_; + /** + * Default Constructor. + */ + constructor(); + /** + *

The data from the loaded file after a successful call to the {@link load load()} method.

+ * + *

If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), + * an {@link LogicError exception} will be thrown when you try to get the value of this property.

+ * + *

All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. + *

+ */ + data: any; + /** + *

The name of the file on the local disk.

+ * + *

If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), + * an {@link LogicError exception} will be thrown when you try to get the value of this property.

+ * + *

All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. + *

+ */ + name: string; + /** + *

The filename extension.

+ * + *

A file's extension is the part of the name following (and not including) the final dot ("."). If + * there is no dot in the filename, the extension is null.

+ * + *

If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), + * an {@link LogicError exception} will be thrown when you try to get the value of this property.

+ * + *

All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. + *

+ */ + extension: string; + /** + *

The file type, metadata of the {@link extension}.

+ * + *

If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), + * an {@link LogicError exception} will be thrown when you try to get the value of this property.

+ * + *

All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. + *

+ */ + type: string; + /** + *

The size of the file on the local disk in bytes.

+ * + *

If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), + * an {@link LogicError exception} will be thrown when you try to get the value of this property.

+ * + *

All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. + *

+ */ + size: number; + /** + *

The date that the file on the local disk was last modified.

+ * + *

If the {@link FileReference} object was not populated (by a valid call to {@link FileReference.browse}), + * an {@link LogicError exception} will be thrown when you try to get the value of this property.

+ * + *

All the properties of a {@link FileReference} object are populated by calling the {@link browse browse()}. + *

+ */ + modificationDate: Date; + /** + *

Displays a file-browsing dialog box that lets the user select a file to upload. The dialog box is native + * to the user's browser system. The user can select a file on the local computer or from other systems, for + * example, through a UNC path on Windows.

+ * + *

When you call this method and the user successfully selects a file, the properties of this + * {@link FileReference} object are populated with the properties of that file. Each subsequent time that the + * {@link FileReference.browse} method is called, the {@link FileReference} object's properties are reset to + * the file that the user selects in the dialog box. Only one {@link browse browse()} can be performed at a time + * (because only one dialog box can be invoked at a time).

+ * + *

Using the typeFilter parameter, you can determine which files the dialog box displays.

+ * + * @param typeFilter An array of filter strings used to filter the files that are displayed in the dialog box. + * If you omit this parameter, all files are displayed. + */ + browse(...typeFilter: string[]): void; + /** + *

Starts the load of a local file selected by a user.

+ * + *

You must call the {@link FileReference.browse} or {@link FileReferenceList.browse} method before you call + * the {@link load load()} method.

+ * + *

Listeners receive events to indicate the progress, success, or failure of the load. Although you can use + * the {@link FileReferenceList} object to let users select multiple files to load, you must {@link load} the + * {@link FileReferenceList files} one by one. To {@link load} the files one by one, iterate through the + * {@link FileReferenceList.fileList} array of {@link FileReference} objects.

+ * + *

If the file finishes loading successfully, its contents are stored in the {@link data} property.

+ */ + load(): void; + /** + *

Save a file to local filesystem.

+ * + *

{@link FileReference.save} implemented the save function by downloading a file from a hidden anchor tag. + * However, the plan, future's {@link FileReference} will follow such rule:

+ * + *

Opens a dialog box that lets the user save a file to the local filesystem.

+ * + *

The {@link save save()} method first opens an browser-system dialog box that asks the user to enter a + * filename and select a location on the local computer to save the file. When the user selects a location and + * confirms the save operation (for example, by clicking Save), the save process begins. Listeners receive events + * to indicate the progress, success, or failure of the save operation. To ascertain the status of the dialog box + * and the save operation after calling {@link save save()}, your code must listen for events such as cancel, + * open, progress, and complete.

+ * + *

When the file is saved successfully, the properties of the {@link FileReference} object are populated with + * the properties of the local file. The complete event is dispatched if the save is successful.

+ * + *

Only one {@link browse browse()} or {@link save()} session can be performed at a time (because only one + * dialog box can be invoked at a time).

+ * + * @param data The data to be saved. The data can be in one of several formats, and will be treated appropriately. + * @param fileName File name to be saved. + */ + save(data: string, fileName: string): void; + } + /** + *

The {@link FileReferenceList} class provides a means to let users select one or more files for + * {@link FileReference.load loading}. A {@link FileReferenceList} object represents a group of one or more local + * files on the user's disk as an array of {@link FileReference} objects. For detailed information and important + * considerations about {@link FileReference} objects and the FileReference class, which you use with + * {@link FileReferenceList}, see the {@link FileReference} class.

+ * + *

To work with the {@link FileReferenceList} class:

+ *
    + *
  • Instantiate the class: var myFileRef = new FileReferenceList();
  • + *
  • + * Call the {@link FileReferenceList.browse} method, which opens a dialog box that lets the user select one or + * more files for upload: myFileRef.browse(); + *
  • + *
  • + * After the {@link browse browse()} method is called successfully, the {@link fileList} property of the + * {@link FileReferenceList} object is populated with an array of {@link FileReference} objects. + *
  • + *
  • Call {@link FileReference.load} on each element in the {@link fileList} array.
  • + *
+ * + *

The {@link FileReferenceList} class includes a {@link browse browse()} method and a {@link fileList} property + * for working with multiple files.

+ * + * @reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReferenceList.html + * @author Jeongho Nam + */ + class FileReferenceList extends EventDispatcher { + /** + * @hidden + */ + file_list: std.Vector; + /** + * Default Constructor. + */ + constructor(); + /** + *

An array of {@link FileReference} objects.

+ * + *

When the {@link FileReferenceList.browse} method is called and the user has selected one or more files + * from the dialog box that the {@link browse browse()} method opens, this property is populated with an array of + * {@link FileReference} objects, each of which represents the files the user selected.

+ * + *

The {@link fileList} property is populated anew each time {@link browse browse()} is called on that + * {@link FileReferenceList} object.

+ */ + fileList: std.Vector; + /** + *

Displays a file-browsing dialog box that lets the user select one or more local files to upload. The + * dialog box is native to the user's browser system.

+ * + *

When you call this method and the user successfully selects files, the {@link fileList} property of this + * {@link FileReferenceList} object is populated with an array of {@link FileReference} objects, one for each + * file that the user selects. Each subsequent time that the {@link FileReferenceList.browse} method is called, + * the {@link FileReferenceList.fileList} property is reset to the file(s) that the user selects in the dialog + * box.

+ * + *

Using the typeFilter parameter, you can determine which files the dialog box displays.

+ * + *

Only one {@link FileReference.browse}, {@link FileReference.load}, or {@link FileReferenceList.browse} + * session can be performed at a time on a {@link FileReferenceList} object (because only one dialog box can be + * opened at a time).

+ * + * @param typeFilter An array of filter strings used to filter the files that are displayed in the dialog box. + * If you omit this parameter, all files are displayed. + */ + browse(...typeFilter: string[]): void; } } declare namespace samchon.library { @@ -1923,13 +2213,140 @@ declare namespace samchon.library { } declare namespace samchon.protocol { /** + *

An interface of entity.

+ * + *

Entity is a class for standardization of expression method using on network I/O by XML. If + * Invoke is a standard message protocol of Samchon Framework which must be kept, Entity is a + * recommended semi-protocol of message for expressing a data class. Following the semi-protocol + * Entity is not imposed but encouraged.

+ * + *

As we could get advantages from standardization of message for network I/O with Invoke, + * we can get additional advantage from standardizing expression method of data class with Entity. + * We do not need to know a part of network communication. Thus, with the Entity, we can only + * concentrate on entity's own logics and relationships between another entities. Entity does not + * need to how network communications are being done.

+ * + *

I say repeatedly. Expression method of Entity is recommended, but not imposed. It's a semi + * protocol for network I/O but not a essential protocol must be kept. The expression method of + * Entity, using on network I/O, is expressed by XML string.

+ * + *

If your own network system has a critical performance issue on communication data class, + * it would be better to using binary communication (with ByteArray). + * Don't worry about the problem! Invoke also provides methods for binary data (ByteArray).

+ * * @author Jeongho Nam */ - abstract class EntityArray extends std.Vector { + interface IEntity { + /** + *

Construct data of the Entity from a XML object.

+ * + *

Overrides the construct() method and fetch data of member variables from the XML.

+ * + *

By recommended guidance, data representing member variables are contained in properties + * of the put XML object.

+ * + * @param xml An xml used to contruct data of entity. + */ + construct(xml: library.XML): any; + /** + *

Get a key that can identify the Entity uniquely.

+ * + *

If identifier of the Entity is not atomic value, returns a string or paired object + * that can represents the composite identifier.

+ */ + key(): any; + /** + *

A tag name when represented by XML.

+ * + *
    + *
  • + *
+ */ + TAG(): string; + /** + *

Get a XML object represents the Entity.

+ * + *

A member variable (not object, but atomic value like number, string or date) is categorized + * as a property within the framework of entity side. Thus, when overriding a toXML() method and + * archiving member variables to an XML object to return, puts each variable to be a property + * belongs to only a XML object.

+ * + *

Don't archive the member variable of atomic value to XML::value causing enormouse creation + * of XML objects to number of member variables. An Entity must be represented by only a XML + * instance (tag).

+ * + *

Standard Usage.

+ * + * + * + * + * + * + * + *

Non-standard usage abusing value.

+ * + * + * jhnam88 + * Jeongho Nam + * 1988-03-11 + * + * + * master + * Administartor + * 2011-07-28 + * + * + * + * @return An XML object representing the Entity. + */ + toXML(): library.XML; + } + /** + *

An entity, a standard data class.

+ * + *

Entity is a class for standardization of expression method using on network I/O by XML. If + * Invoke is a standard message protocol of Samchon Framework which must be kept, Entity is a + * recommended semi-protocol of message for expressing a data class. Following the semi-protocol + * Entity is not imposed but encouraged.

+ * + *

As we could get advantages from standardization of message for network I/O with Invoke, + * we can get additional advantage from standardizing expression method of data class with Entity. + * We do not need to know a part of network communication. Thus, with the Entity, we can only + * concentrate on entity's own logics and relationships between another entities. Entity does not + * need to how network communications are being done.

+ * + *

I say repeatedly. Expression method of Entity is recommended, but not imposed. It's a semi + * protocol for network I/O but not a essential protocol must be kept. The expression method of + * Entity, using on network I/O, is expressed by XML string.

+ * + *

If your own network system has a critical performance issue on communication data class, + * it would be better to using binary communication (with ByteArray). + * Don't worry about the problem! Invoke also provides methods for binary data (ByteArray).

+ * + * @author Jeongho Nam + */ + abstract class Entity implements IEntity { /** * Default Constructor. */ constructor(); + construct(xml: library.XML): void; + /** + * @inheritdoc + */ + key(): any; + /** + * @inheritdoc + */ + abstract TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + } +} +declare namespace samchon.protocol { + interface IEntityGroup extends IEntity, std.base.IContainer { /** *

Construct data of the Entity from an XML object.

* @@ -1940,8 +2357,6 @@ declare namespace samchon.protocol { * of XML objects representing children are done by abstract method of EntityArray::toXML().

* *

Constructs only data of EntityArray's own.

- * - * @inheritdoc */ construct(xml: library.XML): void; /** @@ -1953,11 +2368,24 @@ declare namespace samchon.protocol { * * @return A new child Entity belongs to EntityArray. */ - protected abstract createChild(xml: library.XML): Ety; + createChild(xml: library.XML): T; /** - * @inheritdoc + *

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. */ - key(): any; + find(key: any): std.Iterator; /** *

Whether have the item or not.

* @@ -1989,15 +2417,11 @@ declare namespace samchon.protocol { * * @return A reference object of the mapped value (_Ty) */ - get(key: string): Ety; - /** - * @inheritdoc - */ - abstract TAG(): string; + get(key: any): T; /** *

A tag name of children objects.

*/ - abstract CHILD_TAG(): string; + CHILD_TAG(): string; /** *

Get an XML object represents the EntityArray.

* @@ -2009,7 +2433,282 @@ declare namespace samchon.protocol { * EntityArray::toXML().

* *

Archives only data of EntityArray's own.

- * + */ + toXML(): library.XML; + } + /** + * @inheritdoc + */ + abstract class EntityArray extends std.Vector implements IEntityGroup { + /** + * @inheritdoc + */ + construct(xml: library.XML): void; + /** + * @inheritdoc + */ + abstract createChild(xml: library.XML): T; + /** + * @inheritdoc + */ + key(): any; + /** + * @inheritdoc + */ + find(key: any): std.VectorIterator; + /** + * @inheritdoc + */ + has(key: any): boolean; + /** + * @inheritdoc + */ + count(key: any): number; + /** + * @inheritdoc + */ + get(key: any): T; + /** + * @inheritdoc + */ + abstract TAG(): string; + /** + * @inheritdoc + */ + abstract CHILD_TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + } + /** + * @inheritdoc + */ + abstract class EntityList extends std.List implements IEntityGroup { + /** + * @inheritdoc + */ + construct(xml: library.XML): void; + /** + * @inheritdoc + */ + abstract createChild(xml: library.XML): T; + /** + * @inheritdoc + */ + key(): any; + /** + * @inheritdoc + */ + find(key: any): std.ListIterator; + /** + * @inheritdoc + */ + has(key: any): boolean; + /** + * @inheritdoc + */ + count(key: any): number; + /** + * @inheritdoc + */ + get(key: any): T; + /** + * @inheritdoc + */ + abstract TAG(): string; + /** + * @inheritdoc + */ + abstract CHILD_TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + } + /** + * @inheritdoc + */ + abstract class EntityDeque extends std.Deque implements IEntityGroup { + /** + * @inheritdoc + */ + construct(xml: library.XML): void; + /** + * @inheritdoc + */ + abstract createChild(xml: library.XML): T; + /** + * @inheritdoc + */ + key(): any; + /** + * @inheritdoc + */ + find(key: any): std.DequeIterator; + /** + * @inheritdoc + */ + has(key: any): boolean; + /** + * @inheritdoc + */ + count(key: any): number; + /** + * @inheritdoc + */ + get(key: any): T; + /** + * @inheritdoc + */ + abstract TAG(): string; + /** + * @inheritdoc + */ + abstract CHILD_TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + } +} +declare namespace samchon.protocol { + /** + * @inheritdoc + */ + interface IEntityCollection extends IEntityGroup, collection.ICollection { + } + /** + * @inheritdoc + */ + abstract class EntityArrayCollection extends collection.ArrayCollection implements IEntityCollection { + /** + * @inheritdoc + */ + construct(xml: library.XML): void; + /** + * @inheritdoc + */ + abstract createChild(xml: library.XML): T; + /** + * @inheritdoc + */ + key(): any; + /** + * @inheritdoc + */ + find(key: any): std.VectorIterator; + /** + * @inheritdoc + */ + has(key: any): boolean; + /** + * @inheritdoc + */ + count(key: any): number; + /** + * @inheritdoc + */ + get(key: any): T; + /** + * @inheritdoc + */ + abstract TAG(): string; + /** + * @inheritdoc + */ + abstract CHILD_TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + } + /** + * @inheritdoc + */ + abstract class EntityListCollection extends collection.ListCollection implements IEntityCollection { + /** + * @inheritdoc + */ + construct(xml: library.XML): void; + /** + * @inheritdoc + */ + abstract createChild(xml: library.XML): T; + /** + * @inheritdoc + */ + key(): any; + /** + * @inheritdoc + */ + find(key: any): std.ListIterator; + /** + * @inheritdoc + */ + has(key: any): boolean; + /** + * @inheritdoc + */ + count(key: any): number; + /** + * @inheritdoc + */ + get(key: any): T; + /** + * @inheritdoc + */ + abstract TAG(): string; + /** + * @inheritdoc + */ + abstract CHILD_TAG(): string; + /** + * @inheritdoc + */ + toXML(): library.XML; + } + /** + * @inheritdoc + */ + abstract class EntityDequeCollection extends collection.DequeCollection implements IEntityCollection { + /** + * @inheritdoc + */ + construct(xml: library.XML): void; + /** + * @inheritdoc + */ + abstract createChild(xml: library.XML): T; + /** + * @inheritdoc + */ + key(): any; + /** + * @inheritdoc + */ + find(key: any): std.DequeIterator; + /** + * @inheritdoc + */ + has(key: any): boolean; + /** + * @inheritdoc + */ + count(key: any): number; + /** + * @inheritdoc + */ + get(key: any): T; + /** + * @inheritdoc + */ + abstract TAG(): string; + /** + * @inheritdoc + */ + abstract CHILD_TAG(): string; + /** * @inheritdoc */ toXML(): library.XML; @@ -2200,97 +2899,6 @@ declare namespace samchon.protocol { toXML(): library.XML; } } -declare namespace samchon.protocol { - /** - *

An interface of entity.

- * - *

Entity is a class for standardization of expression method using on network I/O by XML. If - * Invoke is a standard message protocol of Samchon Framework which must be kept, Entity is a - * recommended semi-protocol of message for expressing a data class. Following the semi-protocol - * Entity is not imposed but encouraged.

- * - *

As we could get advantages from standardization of message for network I/O with Invoke, - * we can get additional advantage from standardizing expression method of data class with Entity. - * We do not need to know a part of network communication. Thus, with the Entity, we can only - * concentrate on entity's own logics and relationships between another entities. Entity does not - * need to how network communications are being done.

- * - *

I say repeatedly. Expression method of Entity is recommended, but not imposed. It's a semi - * protocol for network I/O but not a essential protocol must be kept. The expression method of - * Entity, using on network I/O, is expressed by XML string.

- * - *

If your own network system has a critical performance issue on communication data class, - * it would be better to using binary communication (with ByteArray). - * Don't worry about the problem! Invoke also provides methods for binary data (ByteArray).

- * - * @author Jeongho Nam - */ - interface IEntity { - /** - *

Construct data of the Entity from a XML object.

- * - *

Overrides the construct() method and fetch data of member variables from the XML.

- * - *

By recommended guidance, data representing member variables are contained in properties - * of the put XML object.

- * - * @param xml An xml used to contruct data of entity. - */ - construct(xml: library.XML): any; - /** - *

Get a key that can identify the Entity uniquely.

- * - *

If identifier of the Entity is not atomic value, returns a string or paired object - * that can represents the composite identifier.

- */ - key(): any; - /** - *

A tag name when represented by XML.

- * - *
    - *
  • <TAG {...properties} />
  • - *
- */ - TAG(): string; - /** - *

Get a XML object represents the Entity.

- * - *

A member variable (not object, but atomic value like number, string or date) is categorized - * as a property within the framework of entity side. Thus, when overriding a toXML() method and - * archiving member variables to an XML object to return, puts each variable to be a property - * belongs to only a XML object.

- * - *

Don't archive the member variable of atomic value to XML::value causing enormouse creation - * of XML objects to number of member variables. An Entity must be represented by only a XML - * instance (tag).

- * - * - * - * - * - * - * - * - * - * - *
Standard Usage Non-standard usage abusing value
- * <memberList>
- * <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' />
- <member id='master' name='Administartor' birthdate='2011-07-28' />
-</memberList> - *
- * <member> - * <id>jhnam88</id> - * <name>Jeongho+Nam<name> - * <birthdate>1988-03-11</birthdate> - * </member> - *
- * - * @return An XML object representing the Entity. - */ - toXML(): library.XML; - } -} declare namespace samchon.protocol { /** *

An interface for Invoke message chain.

@@ -2364,7 +2972,7 @@ declare namespace samchon.protocol { /** * @inheritdoc */ - protected createChild(xml: library.XML): InvokeParameter; + createChild(xml: library.XML): InvokeParameter; /** * Get listener. */ @@ -2493,10 +3101,33 @@ declare namespace samchon.protocol { *

Value of the parameter.

*/ protected value: any; + /** + * Default Constructor. + */ constructor(); + /** + * Initialization Constructor without type specification. + * + * @param name + * @param val + */ constructor(name: string, val: any); + /** + * Initialization Constructor. + * + * @param name + * @param type + * @param val + */ constructor(name: string, type: string, val: any); + /** + * @inheritdoc + */ construct(xml: library.XML): void; + setValue(value: any): void; + /** + * @inheritdoc + */ key(): any; /** * Get name. @@ -2510,7 +3141,13 @@ declare namespace samchon.protocol { * Get value. */ getValue(): any; + /** + * @inheritdoc + */ TAG(): string; + /** + * @inheritdoc + */ toXML(): library.XML; } } @@ -2546,10 +3183,7 @@ declare namespace samchon.protocol { *

A socket for network I/O.

*/ private socket; - /** - *

Unused string from a server.

- */ - private str; + private binary_invoke; /** *

An open-event listener.

*/ @@ -2581,7 +3215,7 @@ declare namespace samchon.protocol { * Local untrusted SWF files may not communicate with the Internet. You can work around * this limitation by reclassifying the file as local-with-networking or as trusted. */ - connect(ip: string, port: number): void; + connect(ip: string, port: number, path?: string): void; /** *

Send data to the server.

*/ diff --git a/samchon-library/samchon-library-tests.ts b/samchon-library/samchon-library-tests.ts index a2b0656d5f..186a2f0348 100644 --- a/samchon-library/samchon-library-tests.ts +++ b/samchon-library/samchon-library-tests.ts @@ -1,7 +1,4 @@ /// -declare var global: any; -declare var require: (name: string) => any; - -library = require("samchon-library"); +import library = require("samchon-library"); console.log(library); \ No newline at end of file diff --git a/samchon-library/samchon-library.d.ts b/samchon-library/samchon-library.d.ts index 3daecf0937..1ae5be40e5 100644 --- a/samchon-library/samchon-library.d.ts +++ b/samchon-library/samchon-library.d.ts @@ -3,21 +3,11 @@ // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// ------------------------------------------------------------------------------------ -// In Samchon Collection, merging multiple 'ts' files to a module is not possible yet. -// Instead of using "import" instruction, use such trick: -// -// -// declare var global: any; -// declare var require: Function; -// -// library = require("samchon-library"); -// let xml: library.XML = new library.XML(); -// -// -// Those declaration of global and require can be substituted by using "node.d.ts" -// ------------------------------------------------------------------------------------ - /// -declare var library: typeof samchon.library; \ No newline at end of file +declare module "samchon-library" +{ + import library = samchon.library; + export = library; +} + diff --git a/typescript-stl/typescript-stl-tests.ts b/typescript-stl/typescript-stl-tests.ts index aebf205f06..cc684cde7e 100644 --- a/typescript-stl/typescript-stl-tests.ts +++ b/typescript-stl/typescript-stl-tests.ts @@ -1,7 +1,4 @@ /// -declare var global: any; -declare var require: any; - -global["std"] = require("typescript-stl"); +import std = require("typescript-stl"); std.example.test_all(); \ No newline at end of file diff --git a/typescript-stl/typescript-stl.d.ts b/typescript-stl/typescript-stl.d.ts index 0ef62635e8..9baa19ec30 100644 --- a/typescript-stl/typescript-stl.d.ts +++ b/typescript-stl/typescript-stl.d.ts @@ -1,22 +1,12 @@ -// Type definitions for TypeScript-STL v1.0.0-rc.1 +// Type definitions for TypeScript-STL v1.0.0-rc.2 // Project: https://github.com/samchon/stl // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// ------------------------------------------------------------------------------------ -// In TypeScript, merging multiple 'ts' files to a module is not possible yet. -// Instead of using "import" instruction, use such trick: -// -// -// declare var global: any; -// declare var require: Function; -// -// global["std"] = require("typescript-stl"); -// let list: std.List = new std.List(); -// -// -// Those declaration of global and require can be substituted by using "node.d.ts" -// ------------------------------------------------------------------------------------ +declare module "typescript-stl" +{ + export = std; +} /** *

TypeScript-STL

@@ -25,138 +15,11 @@ * *

GitHub Repository: https://github.com/samchon/stl

* - * - *

Introduction

*

STL (Standard Template Library) Containers and Algorithms for TypeScript.

* *

TypeScript-STL is a TypeScript's Standard Template Library who is migrated from C++ STL. Most of classes * and functions of STL have implemented. Just enjoy it.

* - *

Abstract Containers

- * - *

Containers

- * - * - *

Global Functions

- * - * - * - *

References

- *

You can learn and explore about TypeScript-STL more deeply with such below:

- * - * - * - *

Installation

- *

Node

- * npm install -g typescript-stl - * - *
TypeScript
- * - * // SOMEWHERE PLACE NODE AND STL HEADERS EXIST - * /// - * /// - * - * global["std"] = require("typescript-stl"); - * let list: std.List = new std.List(); - * - * - *
Pure JavaScript
- * - * var std = require("typescript-stl"); - * var list = new std.List(); - * - * - *

Browser

- *
In HTML Document
- * - *
TypeScript, reference difinitions (header)
- * - * /// - * - * - * - *

Index of Guidance, Wiki

- * - * * @author Jeongho Nam */ declare namespace std { @@ -2802,7 +2665,9 @@ declare namespace std.base { /** *

An abstract container.

* - *

+ *

+ * + *

* *

Container properties

*
@@ -2921,7 +2786,9 @@ declare namespace std { *

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 @@ -3005,7 +2872,9 @@ declare namespace std { * 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 @@ -3235,7 +3104,9 @@ declare namespace std { * the end, {@link Deque Deques} perform worse and have less consistent iterators and references than * {@link List Lists}.

* - *

+ *

+ * + *

* *

Container properties

*
@@ -3523,7 +3394,9 @@ declare namespace std { /** *

An iterator of {@link Deque}.

* - *

+ *

+ * + *

* * @author Jeongho Nam */ @@ -3593,7 +3466,9 @@ declare namespace std { /** *

A reverse-iterator of Deque.

* - *

+ *

+ * + *

* * @param Type of the elements. * @@ -3668,7 +3543,8 @@ declare namespace std { *

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 @@ -3716,7 +3592,8 @@ declare namespace std { * *

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

* - *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/logic_error * @author Jeongho Nam @@ -3741,7 +3618,8 @@ declare namespace std { *

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

* - *

+ *

< + * img src="http://samchon.github.io/stl/api/assets/images/design/exceptions.png" style="max-width: 100%" />

* * @reference http://www.cplusplus.com/reference/stdexcept/domain_error * @author Jeongho Nam @@ -3762,7 +3640,8 @@ declare namespace std { *

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 @@ -3783,7 +3662,8 @@ declare namespace std { *

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 @@ -3805,7 +3685,8 @@ declare namespace std { * 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 @@ -3826,7 +3707,8 @@ declare namespace std { * *

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

* - *

+ *

+ *

* * @reference http://www.cplusplus.com/reference/stdexcept/runtime_error * @author Jeongho Nam @@ -3847,7 +3729,8 @@ declare namespace std { *

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/outflow_error * @author Jeongho Nam @@ -3868,7 +3751,8 @@ declare namespace std { *

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 @@ -3890,7 +3774,8 @@ declare namespace std { *

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 @@ -4451,7 +4336,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

*
@@ -4588,7 +4474,7 @@ declare namespace std.base { * (i.e., its reverse beginning).

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

+ * beginning of the container.

* *

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

@@ -4852,7 +4738,8 @@ declare namespace std { /** *

An iterator of {@link MapContainer map container}.

* - *

+ *

+ *

* * @author Jeongho Nam */ @@ -4922,7 +4809,8 @@ declare namespace std { /** *

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

* - *

+ *

+ *

* * @author Jeongho Nam */ @@ -4961,7 +4849,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

*
@@ -5114,7 +5003,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

*
@@ -5202,246 +5092,6 @@ declare namespace std.base { swap(obj: MultiMap): void; } } -declare namespace std.base { - /** - *

Common interface for hash map.

- * - *

{@link IHashMap}s are associative containers that store elements formed by the combination of - * a key value and a mapped value.

- * - *

In an {@link IHashMap}, 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 IHashMap} 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.
- *
- * - * @param Type of the key values. - * Each element in an {@link IHashMap} is identified by a key value. - * @param Type of the mapped value. - * Each element in an {@link IHashMap} is used to store some data as its mapped value. - * - * @reference http://www.cplusplus.com/reference/unordered_map - * @author Jeongho Nam - */ - interface IHashMap { - /** - *

Return iterator to beginning.

- * - *

Returns an iterator pointing to the first element in the {@link IHashMap}.

- * - *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its - * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the - * container, until invalidated.

- * - * @return An iterator to the first element in the container. - */ - begin(): MapIterator; - /** - *

Return iterator to beginning.

- * - *

Returns an iterator pointing to the first element in one of buckets in the {@link IHashMap}.

- * - *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its - * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the - * bucket, until invalidated.

- * - * @param index Bucket number. This shall be lower than {@link bucket_count}. - * - * @return An iterator to the first element in the bucket. - */ - begin(index: number): MapIterator; - /** - *

Return iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

- * - *

The iterator returned by end does not point to any element, but to the position that follows the last - * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall - * not be dereferenced - it is generally used to describe the open-end of a range, such as - * [begin, end).

- * - *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any - * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), - * until invalidated.

- * - * @return An iterator to the element past the end of the container. - */ - end(): MapIterator; - /** - *

Return iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

- * - *

The iterator returned by end does not point to any element, but to the position that follows the last - * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall - * not be dereferenced - it is generally used to describe the open-end of a range, such as - * [begin, end).

- * - *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any - * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), - * until invalidated.

- * - * @param index Bucket number. This shall be lower than {@link bucket_count}. - * - * @return An iterator to the element past the end of the bucket. - */ - end(index: number): MapIterator; - rbegin(): MapReverseIterator; - rbegin(index: number): MapReverseIterator; - rend(): MapReverseIterator; - rend(index: number): MapReverseIterator; - /** - *

Return number of buckets.

- * - *

Returns the number of buckets in the {@link IHashMap} container.

- * - *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the - * hash value of their key.

- * - *

The number of buckets influences directly the {@link load_factor load factor} of the container's hash - * table (and thus the probability of collision). The container automatically increases the number of buckets to - * keep the load factor below a specific threshold (its {@link max_load_factor}), causing a {@link rehash} each - * time the number of buckets needs to be increased.

- * - * @return The current amount of buckets. - */ - bucket_count(): number; - /** - *

Return bucket size.

- * - *

Returns the number of elements in bucket n.

- * - *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the hash - * value of their key.

- * - *

The number of elements in a bucket influences the time it takes to access a particular element in the - * bucket. The container automatically increases the number of buckets to keep the {@link load_cator load factor} - * (which is the average bucket size) below its {@link max_load_factor}.

- * - * @param n Bucket number. This shall be lower than {@link bucket_count}. - * - * @return The number of elements in bucket n. - */ - bucket_size(n: number): number; - /** - *

Get maximum load factor.

- * - *

Returns the current maximum load factor for the {@link HashMultiMap} container.

- * - *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the - * number of buckets ({@link bucket_count}).

- * - *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

- * - *

The load factor influences the probability of collision in the hash table (i.e., the probability of two - * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold - * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

- * - *

Note though, that implementations may impose an upper limit on the number of buckets (see - * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

- * - * @return The current load factor. - */ - max_load_factor(): number; - /** - *

Set maximum load factor.

- * - *

Sets z as the cnew maximum load factor for the {@link HashMultiMap} container.

- * - *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the - * number of buckets ({@link bucket_count}).

- * - *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

- * - *

The load factor influences the probability of collision in the hash table (i.e., the probability of two - * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold - * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

- * - *

Note though, that implementations may impose an upper limit on the number of buckets (see - * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

- * - * @param z The new maximum load factor. - */ - max_load_factor(z: number): void; - /** - *

Locate element's bucket.

- * - *

Returns the bucket number where the element with key is located.

- * - *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the - * hash value of their key. Buckets are numbered from 0 to ({@link bucket_count} - 1).

- * - *

Individual elements in a bucket can be accessed by means of the range iterators returned by - * {@link begin} and {@link end}.

- * - * @param key Key whose bucket is to be located. - */ - bucket(key: Key): number; - /** - *

Request a capacity change.

- * - *

Sets the number of buckets in the container ({@link bucket_count}) to the most appropriate to contain at - * least n elements.

- * - *

If n is greater than the current {@link bucket_count} multiplied by the {@link max_load_factor}, - * the container's {@link bucket_count} is increased and a {@link rehash} is forced.

- * - *

If n is lower than that, the function may have no effect.

- * - * @param n The number of elements requested as minimum capacity. - */ - reserve(n: number): void; - /** - *

Set number of buckets.

- * - *

Sets the number of buckets in the container to n or more.

- * - *

If n is greater than the current number of buckets in the container ({@link bucket_count}), a - * {@link HashBuckets.rehash rehash} is forced. The new {@link bucket_count bucket count} can either be equal or - * greater than n.

- * - *

If n is lower than the current number of buckets in the container ({@link bucket_count}), the - * function may have no effect on the {@link bucket_count bucket count} and may not force a - * {@link HashBuckets.rehash rehash}.

- * - *

A {@link HashBuckets.rehash rehash} is the reconstruction of the hash table: All the elements in the - * container are rearranged according to their hash value into the new set of buckets. This may alter the order - * of iteration of elements within the container.

- * - *

{@link HashBuckets.rehash Rehashes} are automatically performed by the container whenever its - * {@link load_factor load factor} is going to surpass its {@link max_load_factor} in an operation.

- * - *

Notice that this function expects the number of buckets as argument. A similar function exists, - * {@link reserve}, that expects the number of elements in the container as argument.

- * - * @param n The minimum number of buckets for the container hash table. - */ - rehash(n: number): void; - } -} declare namespace std { /** *

Hashed, unordered map.

@@ -5462,7 +5112,8 @@ declare namespace std { *

{@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

*
@@ -5618,7 +5269,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

*
@@ -5776,7 +5428,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

*
@@ -6056,7 +5709,8 @@ declare namespace std { /** *

An iterator of a Set.

* - *

+ *

+ *

* * @author Jeongho Nam */ @@ -6114,7 +5768,8 @@ declare namespace std { /** *

A reverse-iterator of Set.

* - *

+ *

+ *

* * @param Type of the elements. * @@ -6143,7 +5798,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

*
@@ -6223,7 +5879,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

*
@@ -6275,243 +5932,6 @@ declare namespace std.base { swap(obj: MultiSet): void; } } -declare namespace std.base { - /** - *

A common interface for hash set.

- * - *

{@link IHashSet}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 IHashSet}, 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 IHashSet} cannot be - * modified once in the container - they can be inserted and removed, though.

- * - *

Internally, the elements in the {@link IHashSet} 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 IHashSet} 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.
- *
- * - * @param Type of the elements. - * Each element in an {@link IHashSet} is also uniquely identified by this value. - * - * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set - * @author Jeongho Nam - */ - interface IHashSet { - /** - *

Return iterator to beginning.

- * - *

Returns an iterator pointing to the first element in the {@link IHashSet}.

- * - *

Notice that an {@link IHashSet} object makes no guarantees on which specific element is considered its - * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the - * container, until invalidated.

- * - * @return An iterator to the first element in the container. - */ - begin(): SetIterator; - /** - *

Return iterator to beginning.

- * - *

Returns an iterator pointing to the first element in one of buckets in the {@link IHashSet}.

- * - *

Notice that an {@link IHashSet} object makes no guarantees on which specific element is considered its - * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the - * bucket, until invalidated.

- * - * @param index Bucket number. This shall be lower than {@link bucket_count}. - * - * @return An iterator to the first element in the bucket. - */ - begin(index: number): SetIterator; - /** - *

Return iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

- * - *

The iterator returned by end does not point to any element, but to the position that follows the last - * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall - * not be dereferenced - it is generally used to describe the open-end of a range, such as - * [begin, end).

- * - *

Notice that an {@link IHashSet} object makes no guarantees on which order its elements follow. But, in any - * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), - * until invalidated.

- * - * @return An iterator to the element past the end of the container. - */ - end(): SetIterator; - /** - *

Return iterator to end.

- * - *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

- * - *

The iterator returned by end does not point to any element, but to the position that follows the last - * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall - * not be dereferenced - it is generally used to describe the open-end of a range, such as - * [begin, end).

- * - *

Notice that an {@link IHashSet} object makes no guarantees on which order its elements follow. But, in any - * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), - * until invalidated.

- * - * @param index Bucket number. This shall be lower than {@link bucket_count}. - * - * @return An iterator to the element past the end of the bucket. - */ - end(index: number): SetIterator; - rbegin(): SetReverseIterator; - rbegin(index: number): SetReverseIterator; - rend(): SetReverseIterator; - rend(index: number): SetReverseIterator; - /** - *

Return number of buckets.

- * - *

Returns the number of buckets in the {@link IHashSet} container.

- * - *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the - * hash value of their key.

- * - *

The number of buckets influences directly the {@link load_factor load factor} of the container's hash - * table (and thus the probability of collision). The container automatically increases the number of buckets to - * keep the load factor below a specific threshold (its {@link max_load_factor}), causing a {@link rehash} each - * time the number of buckets needs to be increased.

- * - * @return The current amount of buckets. - */ - bucket_count(): number; - /** - *

Return bucket size.

- * - *

Returns the number of elements in bucket n.

- * - *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the hash - * value of their key.

- * - *

The number of elements in a bucket influences the time it takes to access a particular element in the - * bucket. The container automatically increases the number of buckets to keep the {@link load_cator load factor} - * (which is the average bucket size) below its {@link max_load_factor}.

- * - * @param n Bucket number. This shall be lower than {@link bucket_count}. - * - * @return The number of elements in bucket n. - */ - bucket_size(n: number): number; - /** - *

Get maximum load factor.

- * - *

Returns the current maximum load factor for the {@link HashMultiMap} container.

- * - *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the - * number of buckets ({@link bucket_count}).

- * - *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

- * - *

The load factor influences the probability of collision in the hash table (i.e., the probability of two - * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold - * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

- * - *

Note though, that implementations may impose an upper limit on the number of buckets (see - * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

- * - * @return The current load factor. - */ - max_load_factor(): number; - /** - *

Set maximum load factor.

- * - *

Sets z as the cnew maximum load factor for the {@link HashMultiMap} container.

- * - *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the - * number of buckets ({@link bucket_count}).

- * - *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

- * - *

The load factor influences the probability of collision in the hash table (i.e., the probability of two - * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold - * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

- * - *

Note though, that implementations may impose an upper limit on the number of buckets (see - * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

- * - * @param z The new maximum load factor. - */ - max_load_factor(z: number): void; - /** - *

Locate element's bucket.

- * - *

Returns the bucket number where the element with key is located.

- * - *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the - * hash value of their key. Buckets are numbered from 0 to ({@link bucket_count} - 1).

- * - *

Individual elements in a bucket can be accessed by means of the range iterators returned by - * {@link begin} and {@link end}.

- * - * @param key Key whose bucket is to be located. - */ - bucket(key: T): number; - /** - *

Request a capacity change.

- * - *

Sets the number of buckets in the container ({@link bucket_count}) to the most appropriate to contain at - * least n elements.

- * - *

If n is greater than the current {@link bucket_count} multiplied by the {@link max_load_factor}, - * the container's {@link bucket_count} is increased and a {@link rehash} is forced.

- * - *

If n is lower than that, the function may have no effect.

- * - * @param n The number of elements requested as minimum capacity. - */ - reserve(n: number): void; - /** - *

Set number of buckets.

- * - *

Sets the number of buckets in the container to n or more.

- * - *

If n is greater than the current number of buckets in the container ({@link bucket_count}), a - * {@link HashBuckets.rehash rehash} is forced. The new {@link bucket_count bucket count} can either be equal or - * greater than n.

- * - *

If n is lower than the current number of buckets in the container ({@link bucket_count}), the - * function may have no effect on the {@link bucket_count bucket count} and may not force a - * {@link HashBuckets.rehash rehash}.

- * - *

A {@link HashBuckets.rehash rehash} is the reconstruction of the hash table: All the elements in the - * container are rearranged according to their hash value into the new set of buckets. This may alter the order - * of iteration of elements within the container.

- * - *

{@link HashBuckets.rehash Rehashes} are automatically performed by the container whenever its - * {@link load_factor load factor} is going to surpass its {@link max_load_factor} in an operation.

- * - *

Notice that this function expects the number of buckets as argument. A similar function exists, - * {@link reserve}, that expects the number of elements in the container as argument.

- * - * @param n The minimum number of buckets for the container hash table. - */ - rehash(n: number): void; - } -} declare namespace std { /** *

Hashed, unordered set.

@@ -6531,7 +5951,8 @@ declare namespace std { * elements by their key, although they are generally less efficient for range iteration through a * subset of their elements.

* - *

+ *

+ *

* *

Container properties

*
@@ -6683,7 +6104,8 @@ declare namespace std { *

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

*
@@ -6844,7 +6266,9 @@ declare namespace std { * 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

*
@@ -7415,7 +6839,9 @@ declare namespace std { /** *

An iterator, node of a List.

* - *

+ *

+ * + *

* * @author Jeongho Nam */ @@ -7475,7 +6901,9 @@ declare namespace std { /** *

A reverse-iterator of List.

* - *

+ *

+ * + *

* * @param Type of the elements. * @@ -7523,7 +6951,9 @@ declare namespace std { * 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. * @@ -7853,7 +7283,9 @@ declare namespace std { * 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. * @@ -7962,7 +7394,8 @@ declare namespace std.base { * so that they can be interpreted when needed as more abstract (and portable) * {@link ErrorCondition error conditions}.

* - *

+ *

+ *

* * @author Jeongho Nam */ @@ -8071,7 +7504,8 @@ declare namespace std { *

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 @@ -8136,7 +7570,8 @@ declare namespace std { * 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 @@ -8263,7 +7698,8 @@ declare namespace std { *

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 @@ -8295,7 +7731,8 @@ declare namespace std { *

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 @@ -8314,121 +7751,6 @@ declare namespace std { constructor(val: number, category: ErrorCategory); } } -declare namespace std.base { - /** - *

Common interface for tree-structured map.

- * - *

{@link ITreeMap ITreeMaps} are associative containers that store elements formed by a combination of - * a key value and a mapped value, following a specific order.

- * - *

In a {@link ITreeMap}, 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 ITreeMap}are always sorted by its key following a - * strict weak ordering criterion indicated by its internal comparison method (of {@link less}).

- * - *

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

- * - *

{@link ITreeMap TreeMultiMaps} 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.
- *
- * - * @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 - * @author Jeongho Nam - */ - interface ITreeMap { - /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the container whose key is not considered to - * go before k (i.e., either it is equivalent or goes after).

- * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(k, element_key) would return false.

- * - *

If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element whose key is not less than k

. - * - *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except - * in the case that the {@link ITreeMap} contains an element with a key equivalent to k: In this - * case, {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} - * returns an iterator pointing to the next element.

- * - * @param k Key to search for. - * - * @return An iterator to the the first element in the container whose key is not considered to go before - * k, or {@link ITreeMap.end} if all keys are considered to go before k. - */ - lower_bound(key: Key): MapIterator; - /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the container whose key is considered to - * go after k

. - * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(k, element_key) would return true.

- * - *

If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element whose key is greater than k

. - * - *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except - * in the case that the map contains an element with a key equivalent to k: In this case - * {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} returns an - * iterator pointing to the next element.

- * - * @param k Key to search for. - * - * @return An iterator to the the first element in the container whose key is considered to go after - * k, or {@link TreeMap.end end} if no keys are considered to go after k. - */ - upper_bound(key: Key): MapIterator; - /** - *

Get range of equal elements.

- * - *

Returns the bounds of a range that includes all the elements in the container which have a key - * equivalent to k

. - * - *

If no matches are found, the range returned has a length of zero, with both iterators pointing to - * the first element that has a key considered to go after k according to the container's internal - * comparison object (key_comp).

- * - *

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

- * - * @param k Key to search for. - * - * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of - * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound - * (the same as {@link upper_bound}). - */ - equal_range(key: Key): Pair, MapIterator>; - } -} declare namespace std { /** *

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

@@ -8451,7 +7773,8 @@ declare namespace std { * *

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

* - *

+ *

+ *

* *

Container properties

*
@@ -8491,7 +7814,7 @@ declare namespace std { * * @param compare A binary predicate determines order of elements. */ - constructor(compare: (left: Key, right: Key) => boolean); + constructor(compare: (x: Key, y: Key) => boolean); /** * Contruct from elements. * @@ -8504,7 +7827,7 @@ declare namespace std { * @param array Elements to be contained. * @param compare A binary predicate determines order of elements. */ - constructor(array: Array>, compare: (left: Key, right: Key) => boolean); + constructor(array: Array>, compare: (x: Key, y: Key) => boolean); /** * Contruct from tuples. * @@ -8517,7 +7840,7 @@ declare namespace std { * @param array Tuples to be contained. * @param compare A binary predicate determines order of elements. */ - constructor(array: Array<[Key, T]>, compare: (left: Key, right: Key) => boolean); + constructor(array: Array<[Key, T]>, compare: (x: Key, y: Key) => boolean); /** * Copy Constructor. * @@ -8530,7 +7853,7 @@ declare namespace std { * @param container Another map to copy. * @param compare A binary predicate determines order of elements. */ - constructor(container: base.MapContainer, compare: (left: Key, right: Key) => boolean); + constructor(container: base.MapContainer, compare: (x: Key, y: Key) => boolean); /** * Range Constructor. * @@ -8545,7 +7868,7 @@ declare namespace std { * @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: Key, right: Key) => boolean); + constructor(begin: Iterator>, end: Iterator>, compare: (x: Key, y: Key) => boolean); /** * @inheritdoc */ @@ -8554,6 +7877,14 @@ declare namespace std { * @inheritdoc */ find(key: Key): MapIterator; + /** + * @inheritdoc + */ + key_comp(): (x: Key, y: Key) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: Pair, y: Pair) => boolean; /** * @inheritdoc */ @@ -8620,7 +7951,8 @@ declare namespace std { * *

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

* - *

+ *

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

* *

Container properties

*
@@ -8663,7 +7995,7 @@ declare namespace std { * * @param compare A binary predicate determines order of elements. */ - constructor(compare: (left: Key, right: Key) => boolean); + constructor(compare: (x: Key, y: Key) => boolean); /** * Contruct from elements. * @@ -8676,7 +8008,7 @@ declare namespace std { * @param array Elements to be contained. * @param compare A binary predicate determines order of elements. */ - constructor(array: Array>, compare: (left: Key, right: Key) => boolean); + constructor(array: Array>, compare: (x: Key, y: Key) => boolean); /** * Contruct from tuples. * @@ -8689,7 +8021,7 @@ declare namespace std { * @param array Tuples to be contained. * @param compare A binary predicate determines order of elements. */ - constructor(array: Array<[Key, T]>, compare: (left: Key, right: Key) => boolean); + constructor(array: Array<[Key, T]>, compare: (x: Key, y: Key) => boolean); /** * Copy Constructor. * @@ -8702,7 +8034,7 @@ declare namespace std { * @param container Another map to copy. * @param compare A binary predicate determines order of elements. */ - constructor(container: base.MapContainer, compare: (left: Key, right: Key) => boolean); + constructor(container: base.MapContainer, compare: (x: Key, y: Key) => boolean); /** * Range Constructor. * @@ -8717,7 +8049,7 @@ declare namespace std { * @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: Key, right: Key) => boolean); + constructor(begin: Iterator>, end: Iterator>, compare: (x: Key, y: Key) => boolean); /** * @inheritdoc */ @@ -8730,6 +8062,14 @@ declare namespace std { * @inheritdoc */ count(key: Key): number; + /** + * @inheritdoc + */ + key_comp(): (x: Key, y: Key) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: Pair, y: Pair) => boolean; /** * @inheritdoc */ @@ -8772,121 +8112,6 @@ declare namespace std { private swap_tree_multimap(obj); } } -declare namespace std.base { - /** - *

A common interface for tree-structured set.

- * - *

{@link ITreeSet TreeMultiSets} are containers that store elements following a specific order.

- * - *

In a {@link ITreeSet}, 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 ITreeSet} 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 ITreeSet TreeMultiSets} are always sorted following a strict - * weak ordering criterion indicated by its internal comparison method (of {@link IComparable.less less}).

- * - *

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

- * - *

{@link ITreeSet 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.
- *
- * - * @param Type of the elements. Each element in a {@link ITreeSet} container is also identified - * by this value (each value is itself also the element's key). - * - * @reference http://www.cplusplus.com/reference/set - * @author Jeongho Nam - */ - interface ITreeSet { - /** - *

Return iterator to lower bound.

- * - *

Returns an iterator pointing to the first element in the container which is not considered to - * go before val (i.e., either it is equivalent or goes after).

- * - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(element,val) would return false.

- * - *

If the {@link ITreeSet} class is instantiated with the default comparison type ({@link less}), - * the function returns an iterator to the first element that is not less than val.

- - *

A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except - * in the case that the {@link ITreeSet} contains elements equivalent to val: In this case - * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas - * {@link upper_bound} returns an iterator pointing to the element following the last.

- * - * @param val Value to compare. - * - * @return An iterator to the the first element in the container which is not considered to go before - * val, or {@link ITreeSet.end} if all elements are considered to go before val. - */ - lower_bound(val: T): SetIterator; - /** - *

Return iterator to upper bound.

- * - *

Returns an iterator pointing to the first element in the container which is considered to go after - * val.

- - *

The function uses its internal comparison object (key_comp) to determine this, returning an - * iterator to the first element for which key_comp(val,element) would return true.

- - *

If the {@code ITreeSet} class is instantiated with the default comparison type (less), the - * function returns an iterator to the first element that is greater than val.

- * - *

A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except - * in the case that the {@ITreeSet} contains elements equivalent to val: In this case - * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas - * {@link upper_bound} returns an iterator pointing to the element following the last.

- * - * @param val Value to compare. - * - * @return An iterator to the the first element in the container which is considered to go after - * val, or {@link TreeSet.end end} if no elements are considered to go after val. - */ - upper_bound(val: T): SetIterator; - /** - *

Get range of equal elements.

- * - *

Returns the bounds of a range that includes all the elements in the container that are equivalent - * to val.

- * - *

If no matches are found, the range returned has a length of zero, with both iterators pointing to - * the first element that is considered to go after val according to the container's - * internal comparison object (key_comp).

- * - *

Two elements of a multiset 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).

- * - * @param key Value to search for. - * - * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of - * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound - * (the same as {@link upper_bound}). - */ - equal_range(val: T): Pair, SetIterator>; - } -} declare namespace std { /** *

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

@@ -8907,7 +8132,8 @@ declare namespace std { * *

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

* - *

+ *

+ *

* *

Container properties

*
@@ -8950,7 +8176,7 @@ declare namespace std { * * @param compare A binary predicate determines order of elements. */ - constructor(compare: (left: T, right: T) => boolean); + constructor(compare: (x: T, y: T) => boolean); /** * Contruct from elements. * @@ -8963,7 +8189,7 @@ declare namespace std { * @param array Elements to be contained. * @param compare A binary predicate determines order of elements. */ - constructor(array: Array, compare: (left: T, right: T) => boolean); + constructor(array: Array, compare: (x: T, y: T) => boolean); /** * Copy Constructor. */ @@ -8974,7 +8200,7 @@ declare namespace std { * @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); + constructor(container: base.IContainer, compare: (x: T, y: T) => boolean); /** * Range Constructor. * @@ -8989,7 +8215,7 @@ declare namespace std { * @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); + constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); /** * @inheritdoc */ @@ -8998,6 +8224,14 @@ declare namespace std { * @inheritdoc */ find(val: T): SetIterator; + /** + * @inheritdoc + */ + key_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: T, y: T) => boolean; /** * @inheritdoc */ @@ -9058,7 +8292,8 @@ declare namespace std { * *

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

* - *

+ *

+ *

* *

Container properties

*
@@ -9101,7 +8336,7 @@ declare namespace std { * * @param compare A binary predicate determines order of elements. */ - constructor(compare: (left: T, right: T) => boolean); + constructor(compare: (x: T, y: T) => boolean); /** * Contruct from elements. * @@ -9114,7 +8349,7 @@ declare namespace std { * @param array Elements to be contained. * @param compare A binary predicate determines order of elements. */ - constructor(array: Array, compare: (left: T, right: T) => boolean); + constructor(array: Array, compare: (x: T, y: T) => boolean); /** * Copy Constructor. */ @@ -9125,7 +8360,7 @@ declare namespace std { * @param container A container to be copied. * @param compare A binary predicate determines order of elements. */ - constructor(container: base.Container, compare: (left: T, right: T) => boolean); + constructor(container: base.Container, compare: (x: T, y: T) => boolean); /** * Range Constructor. * @@ -9140,7 +8375,7 @@ declare namespace std { * @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); + constructor(begin: Iterator, end: Iterator, compare: (x: T, y: T) => boolean); /** * @inheritdoc */ @@ -9153,6 +8388,14 @@ declare namespace std { * @inheritdoc */ count(val: T): number; + /** + * @inheritdoc + */ + key_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + value_comp(): (x: T, y: T) => boolean; /** * @inheritdoc */ @@ -9298,7 +8541,9 @@ declare namespace std { * end, they perform worse than the others, and have less consistent iterators and references than {@link List}s. *

* - *

+ *

+ * + *

* *

Container properties

*
@@ -9682,7 +8927,9 @@ declare namespace std { /** *

An iterator of Vector.

* - *

+ *

+ * + *

* * @param Type of the elements. * @@ -9757,7 +9004,9 @@ declare namespace std { /** *

A reverse-iterator of Vector.

* - *

+ *

+ * + *

* * @param Type of the elements. * @@ -9779,6 +9028,1172 @@ declare namespace std { 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, + RATIO = 1, + MAX_RATIO = 2, + } + /** + *

Hask buckets.

+ * + * @author Jeongho Nam + */ + class HashBuckets { + private buckets_; + private item_size_; + /** + * Default Constructor. + */ + constructor(); + /** + *

Reconstruction of hash table.

+ * + *

All the elements in the hash buckets are rearranged according to their hash value into the new set of + * buckets. This may alter the order of iteration of elements within the container.

+ * + *

Notice that {@link rehash rehashes} are automatically performed whenever its number of elements is going + * to greater than its own {@link capacity}.

+ * + * @param size Number of bucket size to rehash. + */ + rehash(size: number): void; + clear(): void; + size(): number; + item_size(): number; + capacity(): number; + at(index: number): Vector; + hash_index(val: T): number; + insert(val: T): void; + erase(val: T): void; + } +} +declare namespace std.base { + /** + *

Common interface for hash map.

+ * + *

{@link IHashMap}s are associative containers that store elements formed by the combination of + * a key value and a mapped value.

+ * + *

In an {@link IHashMap}, 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 IHashMap} 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.
+ *
+ * + * @param Type of the key values. + * Each element in an {@link IHashMap} is identified by a key value. + * @param Type of the mapped value. + * Each element in an {@link IHashMap} is used to store some data as its mapped value. + * + * @reference http://www.cplusplus.com/reference/unordered_map + * @author Jeongho Nam + */ + interface IHashMap { + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the {@link IHashMap}.

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * container, until invalidated.

+ * + * @return An iterator to the first element in the container. + */ + begin(): MapIterator; + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in one of buckets in the {@link IHashMap}.

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * bucket, until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the first element in the bucket. + */ + begin(index: number): MapIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @return An iterator to the element past the end of the container. + */ + end(): MapIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the element past the end of the bucket. + */ + end(index: number): MapIterator; + /** + *

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

+ * + *

Returns a {@link MapReverseIterator reverse iterator} pointing to the last element in the {@link IHashMap} + * (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}.

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * bucket, until invalidated.

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

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

+ * + *

Returns a {@link MapReverseIterator reverse iterator} pointing to the last element in one of buckets in the + * {@link IHashMap} (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}.

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * bucket, until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return A {@link MapReverseIterator reverse iterator} to the reverse beginning of the sequence + */ + rbegin(index: number): 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 IHashMap hash map container} (which is considered its reverse end).

+ * + *

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

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @return A {@link MapReverseIterator reverse iterator} to the reverse end of the sequence. + */ + rend(): 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 one of buckets in the {@link IHashMap hash map container} (which is considered its + * reverse end).

+ * + *

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

+ * + *

Notice that an {@link IHashMap} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return A {@link MapReverseIterator reverse iterator} to the reverse end of the sequence. + */ + rend(index: number): MapReverseIterator; + /** + *

Return number of buckets.

+ * + *

Returns the number of buckets in the {@link IHashMap} container.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key.

+ * + *

The number of buckets influences directly the {@link load_factor load factor} of the container's hash + * table (and thus the probability of collision). The container automatically increases the number of buckets to + * keep the load factor below a specific threshold (its {@link max_load_factor}), causing a {@link rehash} each + * time the number of buckets needs to be increased.

+ * + * @return The current amount of buckets. + */ + bucket_count(): number; + /** + *

Return bucket size.

+ * + *

Returns the number of elements in bucket n.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the hash + * value of their key.

+ * + *

The number of elements in a bucket influences the time it takes to access a particular element in the + * bucket. The container automatically increases the number of buckets to keep the {@link load_cator load factor} + * (which is the average bucket size) below its {@link max_load_factor}.

+ * + * @param n Bucket number. This shall be lower than {@link bucket_count}. + * + * @return The number of elements in bucket n. + */ + bucket_size(n: number): number; + /** + *

Get maximum load factor.

+ * + *

Returns the current maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @return The current load factor. + */ + max_load_factor(): number; + /** + *

Set maximum load factor.

+ * + *

Sets z as the cnew maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @param z The new maximum load factor. + */ + max_load_factor(z: number): void; + /** + *

Locate element's bucket.

+ * + *

Returns the bucket number where the element with key is located.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key. Buckets are numbered from 0 to ({@link bucket_count} - 1).

+ * + *

Individual elements in a bucket can be accessed by means of the range iterators returned by + * {@link begin} and {@link end}.

+ * + * @param key Key whose bucket is to be located. + */ + bucket(key: Key): number; + /** + *

Request a capacity change.

+ * + *

Sets the number of buckets in the container ({@link bucket_count}) to the most appropriate to contain at + * least n elements.

+ * + *

If n is greater than the current {@link bucket_count} multiplied by the {@link max_load_factor}, + * the container's {@link bucket_count} is increased and a {@link rehash} is forced.

+ * + *

If n is lower than that, the function may have no effect.

+ * + * @param n The number of elements requested as minimum capacity. + */ + reserve(n: number): void; + /** + *

Set number of buckets.

+ * + *

Sets the number of buckets in the container to n or more.

+ * + *

If n is greater than the current number of buckets in the container ({@link bucket_count}), a + * {@link HashBuckets.rehash rehash} is forced. The new {@link bucket_count bucket count} can either be equal or + * greater than n.

+ * + *

If n is lower than the current number of buckets in the container ({@link bucket_count}), the + * function may have no effect on the {@link bucket_count bucket count} and may not force a + * {@link HashBuckets.rehash rehash}.

+ * + *

A {@link HashBuckets.rehash rehash} is the reconstruction of the hash table: All the elements in the + * container are rearranged according to their hash value into the new set of buckets. This may alter the order + * of iteration of elements within the container.

+ * + *

{@link HashBuckets.rehash Rehashes} are automatically performed by the container whenever its + * {@link load_factor load factor} is going to surpass its {@link max_load_factor} in an operation.

+ * + *

Notice that this function expects the number of buckets as argument. A similar function exists, + * {@link reserve}, that expects the number of elements in the container as argument.

+ * + * @param n The minimum number of buckets for the container hash table. + */ + rehash(n: number): void; + } +} +declare namespace std.base { + /** + *

Hash buckets storing {@link MapIterator MapIterators}.

+ * + *

+ *

+ * + * @author Jeongho Nam + */ + class MapHashBuckets extends HashBuckets> { + private map; + constructor(map: MapContainer); + find(key: K): MapIterator; + } +} +declare namespace std.base { + /** + *

A common interface for hash set.

+ * + *

{@link IHashSet}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 IHashSet}, 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 IHashSet} cannot be + * modified once in the container - they can be inserted and removed, though.

+ * + *

Internally, the elements in the {@link IHashSet} 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 IHashSet} 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.
+ *
+ * + * @param Type of the elements. + * Each element in an {@link IHashSet} is also uniquely identified by this value. + * + * @reference http://www.cplusplus.com/reference/unordered_set/unordered_set + * @author Jeongho Nam + */ + interface IHashSet { + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in the {@link IHashSet}.

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * container, until invalidated.

+ * + * @return An iterator to the first element in the container. + */ + begin(): SetIterator; + /** + *

Return iterator to beginning.

+ * + *

Returns an iterator pointing to the first element in one of buckets in the {@link IHashSet}.

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which specific element is considered its + * first element. But, in any case, the range that goes from its begin to its end covers all the elements in the + * bucket, until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the first element in the bucket. + */ + begin(index: number): SetIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @return An iterator to the element past the end of the container. + */ + end(): SetIterator; + /** + *

Return iterator to end.

+ * + *

Returns an iterator pointing to the past-the-end element in the {@link HaspMap} container.

+ * + *

The iterator returned by end does not point to any element, but to the position that follows the last + * element in the {@link HaspMap} container (its past-the-end position). Thus, the value returned shall + * not be dereferenced - it is generally used to describe the open-end of a range, such as + * [begin, end).

+ * + *

Notice that an {@link IHashSet} object makes no guarantees on which order its elements follow. But, in any + * case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), + * until invalidated.

+ * + * @param index Bucket number. This shall be lower than {@link bucket_count}. + * + * @return An iterator to the element past the end of the bucket. + */ + end(index: number): SetIterator; + rbegin(): SetReverseIterator; + rbegin(index: number): SetReverseIterator; + rend(): SetReverseIterator; + rend(index: number): SetReverseIterator; + /** + *

Return number of buckets.

+ * + *

Returns the number of buckets in the {@link IHashSet} container.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key.

+ * + *

The number of buckets influences directly the {@link load_factor load factor} of the container's hash + * table (and thus the probability of collision). The container automatically increases the number of buckets to + * keep the load factor below a specific threshold (its {@link max_load_factor}), causing a {@link rehash} each + * time the number of buckets needs to be increased.

+ * + * @return The current amount of buckets. + */ + bucket_count(): number; + /** + *

Return bucket size.

+ * + *

Returns the number of elements in bucket n.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the hash + * value of their key.

+ * + *

The number of elements in a bucket influences the time it takes to access a particular element in the + * bucket. The container automatically increases the number of buckets to keep the {@link load_cator load factor} + * (which is the average bucket size) below its {@link max_load_factor}.

+ * + * @param n Bucket number. This shall be lower than {@link bucket_count}. + * + * @return The number of elements in bucket n. + */ + bucket_size(n: number): number; + /** + *

Get maximum load factor.

+ * + *

Returns the current maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @return The current load factor. + */ + max_load_factor(): number; + /** + *

Set maximum load factor.

+ * + *

Sets z as the cnew maximum load factor for the {@link HashMultiMap} container.

+ * + *

The load factor is the ratio between the number of elements in the container (its {@link size}) and the + * number of buckets ({@link bucket_count}).

+ * + *

By default, {@link HashMultiMap} containers have a {@link max_load_factor} of 1.0.

+ * + *

The load factor influences the probability of collision in the hash table (i.e., the probability of two + * elements being located in the same bucket). The container uses the value of max_load_factor as the threshold + * that forces an increase in the number of buckets (and thus causing a {@link rehash}).

+ * + *

Note though, that implementations may impose an upper limit on the number of buckets (see + * {@link max_bucket_count}), which may force the container to ignore the {@link max_load_factor}.

+ * + * @param z The new maximum load factor. + */ + max_load_factor(z: number): void; + /** + *

Locate element's bucket.

+ * + *

Returns the bucket number where the element with key is located.

+ * + *

A bucket is a slot in the container's internal hash table to which elements are assigned based on the + * hash value of their key. Buckets are numbered from 0 to ({@link bucket_count} - 1).

+ * + *

Individual elements in a bucket can be accessed by means of the range iterators returned by + * {@link begin} and {@link end}.

+ * + * @param key Key whose bucket is to be located. + */ + bucket(key: T): number; + /** + *

Request a capacity change.

+ * + *

Sets the number of buckets in the container ({@link bucket_count}) to the most appropriate to contain at + * least n elements.

+ * + *

If n is greater than the current {@link bucket_count} multiplied by the {@link max_load_factor}, + * the container's {@link bucket_count} is increased and a {@link rehash} is forced.

+ * + *

If n is lower than that, the function may have no effect.

+ * + * @param n The number of elements requested as minimum capacity. + */ + reserve(n: number): void; + /** + *

Set number of buckets.

+ * + *

Sets the number of buckets in the container to n or more.

+ * + *

If n is greater than the current number of buckets in the container ({@link bucket_count}), a + * {@link HashBuckets.rehash rehash} is forced. The new {@link bucket_count bucket count} can either be equal or + * greater than n.

+ * + *

If n is lower than the current number of buckets in the container ({@link bucket_count}), the + * function may have no effect on the {@link bucket_count bucket count} and may not force a + * {@link HashBuckets.rehash rehash}.

+ * + *

A {@link HashBuckets.rehash rehash} is the reconstruction of the hash table: All the elements in the + * container are rearranged according to their hash value into the new set of buckets. This may alter the order + * of iteration of elements within the container.

+ * + *

{@link HashBuckets.rehash Rehashes} are automatically performed by the container whenever its + * {@link load_factor load factor} is going to surpass its {@link max_load_factor} in an operation.

+ * + *

Notice that this function expects the number of buckets as argument. A similar function exists, + * {@link reserve}, that expects the number of elements in the container as argument.

+ * + * @param n The minimum number of buckets for the container hash table. + */ + rehash(n: number): void; + } +} +declare namespace std.base { + /** + *

Hash buckets storing {@link SetIterator SetIterators}.

+ * + *

+ *

+ * + * @author Jeongho Nam + */ + class SetHashBuckets extends HashBuckets> { + private set; + constructor(set: SetContainer); + find(val: T): SetIterator; + } +} +declare namespace std.base { + /** + *

Array

+ * + *

{@link IArray} is an interface for sequence containers representing arrays that can change in + * {@link size}. However, compared to arrays, {@link IArray} objectss consume more memory in exchange for + * the ability to manage storage and grow dynamically in an efficient way.

+ * + *

Both {@link Vector Vectors} and {@link Deque Deques} who implemented {@link IArray} provide a very + * similar interface and can be used for similar purposes, but internally both work in quite different ways: + * While {@link Vector Vectors} 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 Vectors}, but this allows them to grow more efficiently under certain + * circumstances, especially with very long sequences, where reallocations become more expensive.

+ * + *

Both {@link Vector Vectors} and {@link Deque Deques} provide a very similar interface and can be used for + * similar purposes, but internally both work in quite different ways: While {@link Vector Vectors} 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 Vectors}, + * 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 IArray} objects 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
+ *
+ * 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. + * + * @author Jeongho Nam + */ + interface IArrayContainer extends ILinearContainer { + /** + *

Request a change in capacity.

+ * + *

Requests that the {@link IArray container} {@link capacity} be at least enough to contain + * n elements.

+ * + *

If n is greater than the current {@link IArray container} {@link capacity}, the + * function causes the {@link IArray container} to reallocate its storage increasing its + * {@link capacity} to n (or greater).

+ * + *

In all other cases, the function call does not cause a reallocation and the + * {@link IArray container} {@link capacity} is not affected.

+ * + *

This function has no effect on the {@link IArray container} {@link size} and cannot alter + * its elements.

+ * + * @param n Minimum {@link capacity} for the {@link IArray container}. + * Note that the resulting {@link capacity} may be equal or greater than n. + */ + reserve(n: number): void; + /** + *

Return size of allocated storage capacity.

+ * + *

Returns the size of the storage space currently allocated for the {@link IArray container}, + * expressed in terms of elements.

+ * + *

This {@link capacity} is not necessarily equal to the {@link IArray container} {@link size}. + * It can be equal or greater, with the extra space allowing to accommodate for growth without the + * need to reallocate on each insertion.

+ * + *

Notice that this {@link capacity} does not suppose a limit on the {@link size} of the + * {@link IArray container}. When this {@link capacity} is exhausted and more is needed, it is + * automatically expanded by the {@link IArray container} (reallocating it storage space). + * The theoretical limit on the {@link size} of a {@link IArray container} is given by member + * {@link max_size}.

+ * + *

The {@link capacity} of a {@link IArray container} can be explicitly altered by calling member + * {@link IArray.reserve}.

+ * + * @return The size of the currently allocated storage capacity in the {@link IArray container}, + * measured in terms of the number elements it can hold. + */ + capacity(): number; + /** + *

Access element.

+ *

Returns a value to the element at position index in the {@link IArray container}.

+ * + *

The function automatically checks whether index is within the bounds of valid elements + * in the {@link IArray container}, throwing an {@link OutOfRange} exception if it is not (i.e., + * if index is greater or equal than its {@link size}).

+ * + * @param index Position of an element in the + * If this is greater than or equal to the {@link IArray container} {@link size}, an + * exception of type {@link OutOfRange} is thrown. Notice that the first + * element has a position of 0 (not 1). + * + * @return The element at the specified position in the + */ + at(index: number): T; + /** + *

Modify element.

+ *

Replaces an element at the specified position (index) in this {@link IArray container} + * with the specified element (val).

+ * + *

The function automatically checks whether index is within the bounds of valid elements + * in the {@link IArray container}, throwing an {@link OutOfRange} exception if it is not (i.e., if + * index is greater or equal than its {@link size}).

+ * + * @.param index A specified position of the value to replace. + * @param val A value to be stored at the specified position. + * + * @return The previous element had stored at the specified position. + */ + set(index: number, val: T): void; + } +} +declare namespace std.base { + /** + *

Random-access iterator.

+ * + *

{@link IArrayIterator Random-access iterators} are iterators that can be used to access elements at an + * arbitrary offset position relative to the element they point to, offering the same functionality as pointers. + *

+ * + *

{@link IArrayIterator Random-access iterators} are the most complete iterators in terms of functionality. + * All pointer types are also valid {@link IArrayIterator random-access iterators}.

+ * + *

There is not a single type of {@link IArrayIterator random-access iterator}: 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/RandomAccessIterator + * @author Jeongho Nam + */ + interface IArrayIterator extends Iterator { + /** + * Get index, sequence number of the iterator in the source {@link IArray array}. + * + * @return Sequence number of the iterator in the source {@link IArray array}. + */ + index: number; + /** + * @inheritdoc + */ + prev(): IArrayIterator; + /** + * @inheritdoc + */ + next(): IArrayIterator; + } +} +declare namespace std.base { + /** + *

An interface of containers.

+ * + *

{@link IContainer} is an interface designed for sequence containers. Sequence containers of STL + * (Standard Template Library) are based on the {@link IContainer}.

+ * + *

+ * + *

+ * + *

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 elements. + * + * @author Jeongho Nam + */ + interface IContainer { + /** + *

Assign new content to content.

+ * + *

Assigns new contents to the container, replacing its current contents, and modifying its + * {@link size} accordingly.

+ * + * @param begin Input interator of the initial position in a sequence. + * @param end Input interator of the final position in a sequence. + */ + assign>(begin: InputIterator, end: InputIterator): void; + /** + *

Clear content.

+ * + *

Removes all elements from the Container, leaving the container with a size of 0.

+ */ + clear(): void; + /** + *

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(): Iterator; + /** + *

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 IContainer}.{@link begin} to + * specify a range including all the elements in the container.

+ * + *

Note

+ *

Returned iterator from {@link IContainer}.{@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 Container}.{@link begin}. + *

+ * + * @return An iterator to the end element in the + */ + end(): Iterator; + /** + *

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

+ * + *

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

+ * + *

{@link ReverseIterator reverse iterators} iterate backwards: increasing them moves them towards the + * beginning of the

+ * + *

{@link rbegin} points to the element right before the one that would be pointed to by member {@link end}. + *

+ * + * @return A {@link ReverseIterator reverse iterator} to the reverse beginning of the sequence + */ + rbegin(): base.IReverseIterator; + /** + *

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

+ * + *

Returns a {@link ReverseIterator reverse iterator} pointing to the theoretical element preceding the + * first element in the container (which is considered its reverse end).

+ * + *

The range between {@link IContainer}.{@link rbegin} and {@link IContainer}.{@link rend} contains all + * the elements of the container (in reverse order). + * + * @return A {@link ReverseIterator reverse iterator} to the reverse end of the sequence + */ + rend(): base.IReverseIterator; + /** + * Return the number of elements in the Container. + * + * @return The number of elements in the + */ + size(): number; + /** + *

Test whether the container is empty.

+ *

Returns whether the container is empty (i.e. whether its size is 0).

+ * + *

This function does not modify the container in any way. To clear the content of the container, + * see {@link clear clear()}.

+ * + * @return true if the container size is 0, false otherwise. + */ + empty(): boolean; + /** + *

Insert elements.

+ * + *

Appends new elements to the container, and returns the new size of the

+ * + * @param items New elements to insert. + * + * @return New size of the Container. + */ + push(...items: U[]): number; + /** + *

Insert an element.

+ * + *

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

+ * + * @param position Position in the {@link IContainer} where the new element is inserted. + * {@link iterator} is a member type, defined as a {@link Iterator 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: Iterator, val: T): Iterator; + /** + *

Erase an element.

+ * + *

Removes from the container a single element.

+ * + *

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

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

Erase elements.

+ * + *

Removes from the 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. + * + * @return An iterator pointing to the element that followed the last element erased by the function + * call. This is the {@link end Container.end} if the operation erased the last element in + * the sequence. + */ + erase(begin: Iterator, end: Iterator): Iterator; + /** + *

Swap content.

+ * + *

Exchanges the content of the container by the content of obj, which is another + * {@link IContainer 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 IContainer 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 IContainer}. + */ + swap(obj: IContainer): void; + } + interface IReverseIterator extends ReverseIterator, IReverseIterator> { + } +} +declare namespace std.base { + /** + *

An interface for deque

+ * + *
+ * + * @author Jeongho Nam + */ + interface IDequeContainer extends ILinearContainer { + /** + *

Insert element at beginning.

+ * + *

Inserts a new element at the beginning of the {@link IDeque container}, right before its + * current first element. This effectively increases the {@link IDeque container} {@link size} by + * one.

+ * + * @param val Value to be inserted as an element. + */ + push_front(val: T): void; + /** + *

Delete first element.

+ * + *

Removes the first element in the {@link IDeque container}, effectively reducing its + * {@link size} by one.

+ */ + pop_front(): void; + } +} +declare namespace std.base { + /** + *

An interface for linear containers.

+ * + *

+ * + *

+ * + * @author Jeonngho Nam + */ + interface ILinearContainer extends IContainer { + /** + * @inheritdoc + */ + assign>(begin: InputIterator, end: InputIterator): void; + /** + *

Assign container content.

+ * + *

Assigns new contents to the {@link IList container}, replacing its current contents, + * and modifying its {@link size} accordingly.

+ * + * @param n New size for the + * @param val Value to fill the container with. Each of the n elements in the container will + * be initialized to a copy of this value. + */ + assign(n: number, val: T): void; + /** + *

Access first element.

+ *

Returns a value of the first element in the {@link IList container}.

+ * + *

Unlike member {@link end end()}, which returns an iterator just past this element, + * this function returns a direct value.

+ * + *

Calling this function on an {@link empty} {@link IList container} causes undefined behavior.

+ * + * @return A value of the first element of the {@link IList container}. + */ + front(): T; + /** + *

Access last element.

+ *

Returns a value of the last element in the {@link IList container}.

+ * + *

Unlike member {@link end end()}, which returns an iterator just past this element, + * this function returns a direct value.

+ * + *

Calling this function on an {@link empty} {@link IList container} causes undefined behavior.

+ * + * @return A value of the last element of the {@link IList container}. + */ + back(): T; + /** + *

Add element at the end.

+ * + *

Adds a new element at the end of the {@link IList container}, after its current last element. + * This effectively increases the {@link IList container} {@link size} by one.

+ * + * @param val Value to be copied to the new element. + */ + push_back(val: T): void; + /** + *

Delete last element.

+ * + *

Removes the last element in the {@link IList container}, effectively reducing the + * {@link IList container} {@link size} by one.

+ */ + pop_back(): void; + /** + *

Insert an element.

+ * + *

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

+ * + * @param position Position in the {@link IList container} where the new elements are inserted. + * {@link iterator} is a member type, defined as a {@link iterator 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: Iterator, val: T): Iterator; + /** + *

Insert elements by range iterators.

+ * + *

The {@link IList container} is extended by inserting new elements before the element at the + * specified position, effectively increasing the {@link IList container} {@link size} by + * the number of repeating elements n.

+ * + * @param position Position in the {@link IList container} where the new elements are inserted. + * {@link iterator} is a member type, defined as a {@link iterator 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: Iterator, n: number, val: T): Iterator; + /** + *

Insert elements by range iterators.

+ * + *

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

+ * + * @param position Position in the {@link IList container} where the new elements are inserted. + * {@link iterator} is a member type, defined as a {@link iterator 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: Iterator, begin: InputIterator, end: InputIterator): Iterator; + } +} declare namespace std.base { /** *

Red-black Tree.

@@ -9830,7 +10245,8 @@ declare namespace std.base { * * * - *

+ *

* *

These constraints enforce a critical property of red-black trees: the path from the root to the farthest * leaf is no more than twice as long as the path from the root to the nearest leaf. The result is that the tree @@ -9868,6 +10284,7 @@ declare namespace std.base { * Default Constructor. */ constructor(); + clear(): void; /** * Find a node from its contained value. * @@ -10023,7 +10440,8 @@ declare namespace std.base { * the only loop, and any rotations occur after this loop, this proves that a constant number of rotations * occur.

* - *

+ *

* * @param N A node to be inserted or swapped. */ @@ -10056,7 +10474,8 @@ declare namespace std.base { * node are black) is still violated, but now we can resolve this by * continuing to case 5.

* - *

+ *

* * @param N A node to be inserted or swapped. */ @@ -10086,7 +10505,8 @@ declare namespace std.base { * through {@link XTreeNode.parent P}. In each case, this is the only * black node of the three.

* - *

+ *

* * @param N A node to be inserted or swapped. */ @@ -10239,7 +10659,8 @@ declare namespace std.base { /** *

{@link XTreeNode.sibling S} is red.

* - *

+ *

* *

In this case we reverse the colors of {@link XTreeNode.parent P} and * {@link XTreeNode.sibling S}, and then rotate left at {@link XTreeNode.parent P}, turning @@ -10260,7 +10681,8 @@ declare namespace std.base { *

{@link XTreeNode.parent P}, {@link XTreeNode.sibling S}, and {@link XTreeNode.sibling * S}'s children are black.

* - *

+ *

* *

In this case, we simply repaint {@link XTreeNode.sibling S} red. The * result is that all paths passing through {@link XTreeNode.sibling S}, which are precisely those @@ -10283,7 +10705,8 @@ declare namespace std.base { *

{@link XTreeNode.sibling S} and {@link XTreeNode.sibling S}'s children are * black, but {@link XTreeNode.parent P} is red.

* - *

+ *

* *

In this case, we simply exchange the colors of {@link XTreeNode.sibling S} and * {@link XTreeNode.parent P}. This does not affect the number of black @@ -10299,7 +10722,8 @@ declare namespace std.base { * left child is red, {@link XTreeNode.sibling S}'s right child is * black, and N is the left child of its parent.

* - *

+ *

* *

In this case we rotate right at {@link XTreeNode.sibling S}, so that * {@link XTreeNode.sibling S}'s left child becomes {@link XTreeNode.sibling S}'s parent and @@ -10337,7 +10761,8 @@ declare namespace std.base { *

Thus, the paths passing through N pass through one additional * black node.

* - *

+ *

* *

Meanwhile, if a path does not go through N, then there are two possibilities:

*

+ * + *

    @@ -10399,648 +10824,284 @@ declare namespace std.base { } declare namespace std.base { /** - *

    A red-black Tree storing {@link SetIterator SetIterators}.

    + *

    Common interface for tree-structured map.

    * - *

    + *

    {@link ITreeMap ITreeMaps} are associative containers that store elements formed by a combination of + * a key value and a mapped value, following a specific order.

    * - * @author Jeongho Nam - */ - class AtomicTree extends XTree> { - private compare_; - /** - * Default Constructor. - */ - constructor(compare?: (left: T, right: T) => boolean); - find(val: T): XTreeNode>; - find(it: SetIterator): XTreeNode>; - /** - * @hidden - */ - private find_by_val(val); - get_compare(): (left: T, right: T) => boolean; - /** - * @inheritdoc - */ - is_equal_to(left: SetIterator, right: SetIterator): boolean; - /** - * @inheritdoc - */ - is_less(left: SetIterator, right: SetIterator): boolean; - } -} -declare namespace std.base { - /** - *

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

    + *

    In a {@link ITreeMap}, 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:

    * - *

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

    + *

    typedef Pair value_type;

    * - *
      - *
    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. - *
    + *

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

    * - * @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, - RATIO = 1, - MAX_RATIO = 2, - } - /** - *

    Hask buckets.

    + *

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

    * - * @author Jeongho Nam - */ - class HashBuckets { - private buckets_; - private item_size_; - /** - * Default Constructor. - */ - constructor(); - /** - *

    Reconstruction of hash table.

    - * - *

    All the elements in the hash buckets are rearranged according to their hash value into the new set of - * buckets. This may alter the order of iteration of elements within the container.

    - * - *

    Notice that {@link rehash rehashes} are automatically performed whenever its number of elements is going - * to greater than its own {@link capacity}.

    - * - * @param size Number of bucket size to rehash. - */ - rehash(size: number): void; - clear(): void; - size(): number; - item_size(): number; - capacity(): number; - at(index: number): Vector; - hash_index(val: T): number; - insert(val: T): void; - erase(val: T): void; - } -} -declare namespace std.base { - /** - *

    Array

    + *

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

    * - *

    {@link IArray} is an interface for sequence containers representing arrays that can change in - * {@link size}. However, compared to arrays, {@link IArray} objectss consume more memory in exchange for - * the ability to manage storage and grow dynamically in an efficient way.

    - * - *

    Both {@link Vector Vectors} and {@link Deque Deques} who implemented {@link IArray} provide a very - * similar interface and can be used for similar purposes, but internally both work in quite different ways: - * While {@link Vector Vectors} 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 Vectors}, but this allows them to grow more efficiently under certain - * circumstances, especially with very long sequences, where reallocations become more expensive.

    - * - *

    Both {@link Vector Vectors} and {@link Deque Deques} provide a very similar interface and can be used for - * similar purposes, but internally both work in quite different ways: While {@link Vector Vectors} 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 Vectors}, - * 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 IArray} objects 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. - *
    + *
    Associative
    + *
    Elements in associative containers are referenced by their key and not by their absolute + * position in the container.
    * - *
    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. - *
    + *
    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.
    *
    * - * @param Type of the elements. + * @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 * @author Jeongho Nam */ - interface IArrayContainer extends ILinearContainer { + interface ITreeMap { /** - *

    Request a change in capacity.

    + *

    Return key comparison function.

    * - *

    Requests that the {@link IArray container} {@link capacity} be at least enough to contain - * n elements.

    + *

    Returns a references of the comparison function used by the container to compare keys.

    * - *

    If n is greater than the current {@link IArray container} {@link capacity}, the - * function causes the {@link IArray container} to reallocate its storage increasing its - * {@link capacity} to n (or greater).

    + *

    The comparison object of a {@link ITreeMap tree-map object} is set on + * {@link TreeMap.constructor construction}. Its type (Key) is the last parameter of the + * {@link ITreeMap.constructor constructors}. By default, this is a {@link less} function, which returns the same + * as operator<.

    * - *

    In all other cases, the function call does not cause a reallocation and the - * {@link IArray container} {@link capacity} is not affected.

    - * - *

    This function has no effect on the {@link IArray container} {@link size} and cannot alter - * its elements.

    - * - * @param n Minimum {@link capacity} for the {@link IArray container}. - * Note that the resulting {@link capacity} may be equal or greater than n. - */ - reserve(n: number): void; - /** - *

    Return size of allocated storage capacity.

    - * - *

    Returns the size of the storage space currently allocated for the {@link IArray container}, - * expressed in terms of elements.

    - * - *

    This {@link capacity} is not necessarily equal to the {@link IArray container} {@link size}. - * It can be equal or greater, with the extra space allowing to accommodate for growth without the - * need to reallocate on each insertion.

    - * - *

    Notice that this {@link capacity} does not suppose a limit on the {@link size} of the - * {@link IArray container}. When this {@link capacity} is exhausted and more is needed, it is - * automatically expanded by the {@link IArray container} (reallocating it storage space). - * The theoretical limit on the {@link size} of a {@link IArray container} is given by member - * {@link max_size}.

    - * - *

    The {@link capacity} of a {@link IArray container} can be explicitly altered by calling member - * {@link IArray.reserve}.

    - * - * @return The size of the currently allocated storage capacity in the {@link IArray container}, - * measured in terms of the number elements it can hold. - */ - capacity(): number; - /** - *

    Access element.

    - *

    Returns a value to the element at position index in the {@link IArray container}.

    - * - *

    The function automatically checks whether index is within the bounds of valid elements - * in the {@link IArray container}, throwing an {@link OutOfRange} exception if it is not (i.e., - * if index is greater or equal than its {@link size}).

    - * - * @param index Position of an element in the - * If this is greater than or equal to the {@link IArray container} {@link size}, an - * exception of type {@link OutOfRange} is thrown. Notice that the first - * element has a position of 0 (not 1). - * - * @return The element at the specified position in the - */ - at(index: number): T; - /** - *

    Modify element.

    - *

    Replaces an element at the specified position (index) in this {@link IArray container} - * with the specified element (val).

    - * - *

    The function automatically checks whether index is within the bounds of valid elements - * in the {@link IArray container}, throwing an {@link OutOfRange} exception if it is not (i.e., if - * index is greater or equal than its {@link size}).

    - * - * @.param index A specified position of the value to replace. - * @param val A value to be stored at the specified position. - * - * @return The previous element had stored at the specified position. - */ - set(index: number, val: T): void; - } -} -declare namespace std.base { - /** - *

    Random-access iterator.

    - * - *

    {@link IArrayIterator Random-access iterators} are iterators that can be used to access elements at an - * arbitrary offset position relative to the element they point to, offering the same functionality as pointers. - *

    - * - *

    {@link IArrayIterator Random-access iterators} are the most complete iterators in terms of functionality. - * All pointer types are also valid {@link IArrayIterator random-access iterators}.

    - * - *

    There is not a single type of {@link IArrayIterator random-access iterator}: 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/RandomAccessIterator - * @author Jeongho Nam - */ - interface IArrayIterator extends Iterator { - /** - * Get index, sequence number of the iterator in the source {@link IArray array}. - * - * @return Sequence number of the iterator in the source {@link IArray array}. - */ - index: number; - /** - * @inheritdoc - */ - prev(): IArrayIterator; - /** - * @inheritdoc - */ - next(): IArrayIterator; - } -} -declare namespace std.base { - /** - *

    An interface of containers.

    - * - *

    {@link IContainer} is an interface designed for sequence containers. Sequence containers of STL - * (Standard Template Library) are based on the {@link IContainer}.

    - * - *

    - * - *

    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 elements. - * - * @author Jeongho Nam - */ - interface IContainer { - /** - *

    Assign new content to content.

    - * - *

    Assigns new contents to the container, replacing its current contents, and modifying its - * {@link size} accordingly.

    - * - * @param begin Input interator of the initial position in a sequence. - * @param end Input interator of the final position in a sequence. - */ - assign>(begin: InputIterator, end: InputIterator): void; - /** - *

    Clear content.

    - * - *

    Removes all elements from the Container, leaving the container with a size of 0.

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

    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(): Iterator; - /** - *

    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 IContainer}.{@link begin} to - * specify a range including all the elements in the

    - * - *

    Note

    - *

    Returned iterator from {@link IContainer}.{@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 Container}.{@link begin}. + *

    This function determines the order of the elements in the container: it is a function pointer that takes + * two arguments of the same type as the element keys, and returns true if the first argument + * is considered to go before the second in the strict weak ordering it defines, and false otherwise. *

    * - * @return An iterator to the end element in the + *

    Two keys are considered equivalent if {@link key_comp} returns false reflexively (i.e., no + * matter the order in which the keys are passed as arguments).

    + * + * @return The comparison function. */ - end(): Iterator; + key_comp(): (x: Key, y: Key) => boolean; /** - *

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

    + *

    Return value comparison function.

    * - *

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

    + *

    Returns a comparison function that can be used to compare two elements to get whether the key of the first + * one goes before the second.

    * - *

    {@link ReverseIterator reverse iterators} iterate backwards: increasing them moves them towards the - * beginning of the

    + *

    The arguments taken by this function object are of member type std.Pair (defined in + * {@link ITreeMap}), but the mapped type (T) part of the value is not taken into consideration in this + * comparison.

    * - *

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

    + *

    This comparison class returns true if the {@link Pair.first key} of the first argument + * is considered to go before that of the second (according to the strict weak ordering specified by the + * container's comparison function, {@link key_comp}), and false otherwise.

    * - * @return A {@link ReverseIterator reverse iterator} to the reverse beginning of the sequence + * @return The comparison function for element values. */ - rbegin(): base.IReverseIterator; + value_comp(): (x: Pair, y: Pair) => boolean; /** - *

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

    + *

    Return iterator to lower bound.

    * - *

    Returns a {@link ReverseIterator reverse iterator} pointing to the theoretical element preceding the - * first element in the container (which is considered its reverse end).

    + *

    Returns an iterator pointing to the first element in the container whose key is not considered to + * go before k (i.e., either it is equivalent or goes after).

    * - *

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

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(k, element_key) would return false.

    * - * @return A {@link ReverseIterator reverse iterator} to the reverse end of the sequence + *

    If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element whose key is not less than k

    . + * + *

    A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except + * in the case that the {@link ITreeMap} contains an element with a key equivalent to k: In this + * case, {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} + * returns an iterator pointing to the next element.

    + * + * @param k Key to search for. + * + * @return An iterator to the the first element in the container whose key is not considered to go before + * k, or {@link ITreeMap.end} if all keys are considered to go before k. */ - rend(): base.IReverseIterator; + lower_bound(key: Key): MapIterator; /** - * Return the number of elements in the Container. + *

    Return iterator to upper bound.

    * - * @return The number of elements in the + *

    Returns an iterator pointing to the first element in the container whose key is considered to + * go after k

    . + * + *

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(k, element_key) would return true.

    + * + *

    If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element whose key is greater than k

    . + * + *

    A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except + * in the case that the map contains an element with a key equivalent to k: In this case + * {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} returns an + * iterator pointing to the next element.

    + * + * @param k Key to search for. + * + * @return An iterator to the the first element in the container whose key is considered to go after + * k, or {@link TreeMap.end end} if no keys are considered to go after k. */ - size(): number; + upper_bound(key: Key): MapIterator; /** - *

    Test whether the container is empty.

    - *

    Returns whether the container is empty (i.e. whether its size is 0).

    + *

    Get range of equal elements.

    * - *

    This function does not modify the container in any way. To clear the content of the container, - * see {@link clear clear()}.

    + *

    Returns the bounds of a range that includes all the elements in the container which have a key + * equivalent to k

    . * - * @return true if the container size is 0, false otherwise. + *

    If no matches are found, the range returned has a length of zero, with both iterators pointing to + * the first element that has a key considered to go after k according to the container's internal + * comparison object (key_comp).

    + * + *

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

    + * + * @param k Key to search for. + * + * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of + * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound + * (the same as {@link upper_bound}). */ - empty(): boolean; - /** - *

    Insert elements.

    - * - *

    Appends new elements to the container, and returns the new size of the

    - * - * @param items New elements to insert. - * - * @return New size of the Container. - */ - push(...items: U[]): number; - /** - *

    Insert an element.

    - * - *

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

    - * - * @param position Position in the {@link IContainer} where the new element is inserted. - * {@link iterator} is a member type, defined as a {@link Iterator 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: Iterator, val: T): Iterator; - /** - *

    Erase an element.

    - * - *

    Removes from the container a single element.

    - * - *

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

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

    Erase elements.

    - * - *

    Removes from the 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. - * - * @return An iterator pointing to the element that followed the last element erased by the function - * call. This is the {@link end Container.end} if the operation erased the last element in - * the sequence. - */ - erase(begin: Iterator, end: Iterator): Iterator; - /** - *

    Swap content.

    - * - *

    Exchanges the content of the container by the content of obj, which is another - * {@link IContainer 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 IContainer 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 IContainer}. - */ - swap(obj: IContainer): void; - } - interface IReverseIterator extends ReverseIterator, IReverseIterator> { + equal_range(key: Key): Pair, MapIterator>; } } declare namespace std.base { /** - *

    An interface for deque

    + *

    A red-black tree storing {@link MapIterator MapIterators}.

    * - *

    - * - * @author Jeongho Nam - */ - interface IDequeContainer extends ILinearContainer { - /** - *

    Insert element at beginning.

    - * - *

    Inserts a new element at the beginning of the {@link IDeque container}, right before its - * current first element. This effectively increases the {@link IDeque container} {@link size} by - * one.

    - * - * @param val Value to be inserted as an element. - */ - push_front(val: T): void; - /** - *

    Delete first element.

    - * - *

    Removes the first element in the {@link IDeque container}, effectively reducing its - * {@link size} by one.

    - */ - pop_front(): void; - } -} -declare namespace std.base { - /** - *

    An interface for linear containers.

    - * - *

    - * - * @author Jeonngho Nam - */ - interface ILinearContainer extends IContainer { - /** - * @inheritdoc - */ - assign>(begin: InputIterator, end: InputIterator): void; - /** - *

    Assign container content.

    - * - *

    Assigns new contents to the {@link IList container}, replacing its current contents, - * and modifying its {@link size} accordingly.

    - * - * @param n New size for the - * @param val Value to fill the container with. Each of the n elements in the container will - * be initialized to a copy of this value. - */ - assign(n: number, val: T): void; - /** - *

    Access first element.

    - *

    Returns a value of the first element in the {@link IList container}.

    - * - *

    Unlike member {@link end end()}, which returns an iterator just past this element, - * this function returns a direct value.

    - * - *

    Calling this function on an {@link empty} {@link IList container} causes undefined behavior.

    - * - * @return A value of the first element of the {@link IList container}. - */ - front(): T; - /** - *

    Access last element.

    - *

    Returns a value of the last element in the {@link IList container}.

    - * - *

    Unlike member {@link end end()}, which returns an iterator just past this element, - * this function returns a direct value.

    - * - *

    Calling this function on an {@link empty} {@link IList container} causes undefined behavior.

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

    Add element at the end.

    - * - *

    Adds a new element at the end of the {@link IList container}, after its current last element. - * This effectively increases the {@link IList container} {@link size} by one.

    - * - * @param val Value to be copied to the new element. - */ - push_back(val: T): void; - /** - *

    Delete last element.

    - * - *

    Removes the last element in the {@link IList container}, effectively reducing the - * {@link IList container} {@link size} by one.

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

    Insert an element.

    - * - *

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

    - * - * @param position Position in the {@link IList container} where the new elements are inserted. - * {@link iterator} is a member type, defined as a {@link iterator 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: Iterator, val: T): Iterator; - /** - *

    Insert elements by range iterators.

    - * - *

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

    - * - * @param position Position in the {@link IList container} where the new elements are inserted. - * {@link iterator} is a member type, defined as a {@link iterator 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: Iterator, n: number, val: T): Iterator; - /** - *

    Insert elements by range iterators.

    - * - *

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

    - * - * @param position Position in the {@link IList container} where the new elements are inserted. - * {@link iterator} is a member type, defined as a {@link iterator 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: Iterator, begin: InputIterator, end: InputIterator): Iterator; - } -} -declare namespace std.base { - /** - *

    Hash buckets storing {@link MapIterator MapIterators}.

    - * - *

    - * - * @author Jeongho Nam - */ - class MapHashBuckets extends HashBuckets> { - private map; - constructor(map: MapContainer); - find(key: K): MapIterator; - } -} -declare namespace std.base { - /** - *

    A red-black Tree storing {@link MapIterator MapIterators}.

    - * - *

    + *

    + *

    * * @author Jeongho Nam */ class PairTree extends XTree> { + private map_; private compare_; /** * Default Constructor. */ - constructor(compare?: (left: Key, right: Key) => boolean); + constructor(map: TreeMap | TreeMultiMap, compare?: (x: Key, y: Key) => boolean); find(key: Key): XTreeNode>; find(it: MapIterator): XTreeNode>; /** * @hidden */ private find_by_key(key); - get_compare(): (left: Key, right: Key) => boolean; + /** + *

    Return iterator to lower bound.

    + * + *

    Returns an iterator pointing to the first element in the container whose key is not considered to + * go before k (i.e., either it is equivalent or goes after).

    + * + *

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(k, element_key) would return false.

    + * + *

    If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element whose key is not less than k

    . + * + *

    A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except + * in the case that the {@link ITreeMap} contains an element with a key equivalent to k: In this + * case, {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} + * returns an iterator pointing to the next element.

    + * + * @param k Key to search for. + * + * @return An iterator to the the first element in the container whose key is not considered to go before + * k, or {@link ITreeMap.end} if all keys are considered to go before k. + */ + lower_bound(key: Key): MapIterator; + /** + *

    Return iterator to upper bound.

    + * + *

    Returns an iterator pointing to the first element in the container whose key is considered to + * go after k

    . + * + *

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(k, element_key) would return true.

    + * + *

    If the {@link ITreeMap} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element whose key is greater than k

    . + * + *

    A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except + * in the case that the map contains an element with a key equivalent to k: In this case + * {@link lower_bound} returns an iterator pointing to that element, whereas {@link upper_bound} returns an + * iterator pointing to the next element.

    + * + * @param k Key to search for. + * + * @return An iterator to the the first element in the container whose key is considered to go after + * k, or {@link TreeMap.end end} if no keys are considered to go after k. + */ + upper_bound(key: Key): MapIterator; + /** + *

    Get range of equal elements.

    + * + *

    Returns the bounds of a range that includes all the elements in the container which have a key + * equivalent to k

    . + * + *

    If no matches are found, the range returned has a length of zero, with both iterators pointing to + * the first element that has a key considered to go after k according to the container's internal + * comparison object (key_comp).

    + * + *

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

    + * + * @param k Key to search for. + * + * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of + * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound + * (the same as {@link upper_bound}). + */ + equal_range(key: Key): Pair, MapIterator>; + /** + *

    Return key comparison function.

    + * + *

    Returns a references of the comparison function used by the container to compare keys.

    + * + *

    The comparison object of a {@link ITreeMap tree-map object} is set on + * {@link TreeMap.constructor construction}. Its type (Key) is the last parameter of the + * {@link ITreeMap.constructor constructors}. By default, this is a {@link less} function, which returns the same + * as operator<.

    + * + *

    This function determines the order of the elements in the container: it is a function pointer that takes + * two arguments of the same type as the element keys, and returns true if the first argument + * is considered to go before the second in the strict weak ordering it defines, and false otherwise. + *

    + * + *

    Two keys are considered equivalent if {@link key_comp} returns false reflexively (i.e., no + * matter the order in which the keys are passed as arguments).

    + * + * @return The comparison function. + */ + key_comp(): (x: Key, y: Key) => boolean; + /** + *

    Return value comparison function.

    + * + *

    Returns a comparison function that can be used to compare two elements to get whether the key of the first + * one goes before the second.

    + * + *

    The arguments taken by this function object are of member type std.Pair (defined in + * {@link ITreeMap}), but the mapped type (T) part of the value is not taken into consideration in this + * comparison.

    + * + *

    This comparison class returns true if the {@link Pair.first key} of the first argument + * is considered to go before that of the second (according to the strict weak ordering specified by the + * container's comparison function, {@link key_comp}), and false otherwise.

    + * + * @return The comparison function for element values. + */ + value_comp(): (x: Pair, y: Pair) => boolean; /** * @inheritdoc */ @@ -11053,16 +11114,300 @@ declare namespace std.base { } declare namespace std.base { /** - *

    Hash buckets storing {@link SetIterator SetIterators}.

    + *

    A common interface for tree-structured set.

    * - *

    + *

    {@link ITreeSet TreeMultiSets} are containers that store elements following a specific order.

    + * + *

    In a {@link ITreeSet}, 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 ITreeSet} 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 ITreeSet TreeMultiSets} are always sorted following a strict + * weak ordering criterion indicated by its internal comparison method (of {@link IComparable.less less}).

    + * + *

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

    + * + *

    {@link ITreeSet 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.
    + *
    + * + * @param Type of the elements. Each element in a {@link ITreeSet} container is also identified + * by this value (each value is itself also the element's key). + * + * @reference http://www.cplusplus.com/reference/set + * @author Jeongho Nam + */ + interface ITreeSet { + /** + *

    Return comparison function.

    + * + *

    Returns a copy of the comparison function used by the container.

    + * + *

    By default, this is a {@link less} object, which returns the same as operator<.

    + * + *

    This object determines the order of the elements in the container: it is a function pointer or a function + * object that takes two arguments of the same type as the container elements, and returns true if + * the first argument is considered to go before the second in the strict weak ordering it + * defines, and false otherwise.

    + * + *

    Two elements of a {@link ITreeSet} are considered equivalent if {@link key_comp} returns false + * reflexively (i.e., no matter the order in which the elements are passed as arguments).

    + * + *

    In {@link ITreeSet} containers, the keys to sort the elements are the values (T) themselves, + * therefore {@link key_comp} and its sibling member function {@link value_comp} are equivalent.

    + * + * @return The comparison function. + */ + key_comp(): (x: T, y: T) => boolean; + /** + *

    Return comparison function.

    + * + *

    Returns a copy of the comparison function used by the container.

    + * + *

    By default, this is a {@link less} object, which returns the same as operator<.

    + * + *

    This object determines the order of the elements in the container: it is a function pointer or a function + * object that takes two arguments of the same type as the container elements, and returns true if + * the first argument is considered to go before the second in the strict weak ordering it + * defines, and false otherwise.

    + * + *

    Two elements of a {@link ITreeSet} are considered equivalent if {@link key_comp} returns false + * reflexively (i.e., no matter the order in which the elements are passed as arguments).

    + * + *

    In {@link ITreeSet} containers, the keys to sort the elements are the values (T) themselves, + * therefore {@link key_comp} and its sibling member function {@link value_comp} are equivalent.

    + * + * @return The comparison function. + */ + value_comp(): (x: T, y: T) => boolean; + /** + *

    Return iterator to lower bound.

    + * + *

    Returns an iterator pointing to the first element in the container which is not considered to + * go before val (i.e., either it is equivalent or goes after).

    + * + *

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(element,val) would return false.

    + * + *

    If the {@link ITreeSet} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element that is not less than val.

    + + *

    A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except + * in the case that the {@link ITreeSet} contains elements equivalent to val: In this case + * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas + * {@link upper_bound} returns an iterator pointing to the element following the last.

    + * + * @param val Value to compare. + * + * @return An iterator to the the first element in the container which is not considered to go before + * val, or {@link ITreeSet.end} if all elements are considered to go before val. + */ + lower_bound(val: T): SetIterator; + /** + *

    Return iterator to upper bound.

    + * + *

    Returns an iterator pointing to the first element in the container which is considered to go after + * val.

    + + *

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(val,element) would return true.

    + + *

    If the {@code ITreeSet} class is instantiated with the default comparison type (less), the + * function returns an iterator to the first element that is greater than val.

    + * + *

    A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except + * in the case that the {@ITreeSet} contains elements equivalent to val: In this case + * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas + * {@link upper_bound} returns an iterator pointing to the element following the last.

    + * + * @param val Value to compare. + * + * @return An iterator to the the first element in the container which is considered to go after + * val, or {@link TreeSet.end end} if no elements are considered to go after val. + */ + upper_bound(val: T): SetIterator; + /** + *

    Get range of equal elements.

    + * + *

    Returns the bounds of a range that includes all the elements in the container that are equivalent + * to val.

    + * + *

    If no matches are found, the range returned has a length of zero, with both iterators pointing to + * the first element that is considered to go after val according to the container's + * internal comparison object (key_comp).

    + * + *

    Two elements of a multiset 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).

    + * + * @param key Value to search for. + * + * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of + * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound + * (the same as {@link upper_bound}). + */ + equal_range(val: T): Pair, SetIterator>; + } +} +declare namespace std.base { + /** + *

    A red-black Tree storing {@link SetIterator SetIterators}.

    + * + *

    + *

    * * @author Jeongho Nam */ - class SetHashBuckets extends HashBuckets> { - private set; - constructor(set: SetContainer); - find(val: T): SetIterator; + class AtomicTree extends XTree> { + private set_; + private compare_; + /** + * Default Constructor. + */ + constructor(set: TreeSet | TreeMultiSet, compare?: (x: T, y: T) => boolean); + find(val: T): XTreeNode>; + find(it: SetIterator): XTreeNode>; + /** + * @hidden + */ + private find_by_val(val); + /** + *

    Return iterator to lower bound.

    + * + *

    Returns an iterator pointing to the first element in the container which is not considered to + * go before val (i.e., either it is equivalent or goes after).

    + * + *

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(element,val) would return false.

    + * + *

    If the {@link ITreeSet} class is instantiated with the default comparison type ({@link less}), + * the function returns an iterator to the first element that is not less than val.

    + + *

    A similar member function, {@link upper_bound}, has the same behavior as {@link lower_bound}, except + * in the case that the {@link ITreeSet} contains elements equivalent to val: In this case + * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas + * {@link upper_bound} returns an iterator pointing to the element following the last.

    + * + * @param val Value to compare. + * + * @return An iterator to the the first element in the container which is not considered to go before + * val, or {@link ITreeSet.end} if all elements are considered to go before val. + */ + lower_bound(val: T): SetIterator; + /** + *

    Return iterator to upper bound.

    + * + *

    Returns an iterator pointing to the first element in the container which is considered to go after + * val.

    + + *

    The function uses its internal comparison object (key_comp) to determine this, returning an + * iterator to the first element for which key_comp(val,element) would return true.

    + + *

    If the {@code ITreeSet} class is instantiated with the default comparison type (less), the + * function returns an iterator to the first element that is greater than val.

    + * + *

    A similar member function, {@link lower_bound}, has the same behavior as {@link upper_bound}, except + * in the case that the {@ITreeSet} contains elements equivalent to val: In this case + * {@link lower_bound} returns an iterator pointing to the first of such elements, whereas + * {@link upper_bound} returns an iterator pointing to the element following the last.

    + * + * @param val Value to compare. + * + * @return An iterator to the the first element in the container which is considered to go after + * val, or {@link TreeSet.end end} if no elements are considered to go after val. + */ + upper_bound(val: T): SetIterator; + /** + *

    Get range of equal elements.

    + * + *

    Returns the bounds of a range that includes all the elements in the container that are equivalent + * to val.

    + * + *

    If no matches are found, the range returned has a length of zero, with both iterators pointing to + * the first element that is considered to go after val according to the container's + * internal comparison object (key_comp).

    + * + *

    Two elements of a multiset 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).

    + * + * @param key Value to search for. + * + * @return The function returns a {@link Pair}, whose member {@link Pair.first} is the lower bound of + * the range (the same as {@link lower_bound}), and {@link Pair.second} is the upper bound + * (the same as {@link upper_bound}). + */ + equal_range(val: T): Pair, SetIterator>; + /** + *

    Return comparison function.

    + * + *

    Returns a copy of the comparison function used by the container.

    + * + *

    By default, this is a {@link less} object, which returns the same as operator<.

    + * + *

    This object determines the order of the elements in the container: it is a function pointer or a function + * object that takes two arguments of the same type as the container elements, and returns true if + * the first argument is considered to go before the second in the strict weak ordering it + * defines, and false otherwise.

    + * + *

    Two elements of a {@link ITreeSet} are considered equivalent if {@link key_comp} returns false + * reflexively (i.e., no matter the order in which the elements are passed as arguments).

    + * + *

    In {@link ITreeSet} containers, the keys to sort the elements are the values (T) themselves, + * therefore {@link key_comp} and its sibling member function {@link value_comp} are equivalent.

    + * + * @return The comparison function. + */ + key_comp(): (x: T, y: T) => boolean; + /** + *

    Return comparison function.

    + * + *

    Returns a copy of the comparison function used by the container.

    + * + *

    By default, this is a {@link less} object, which returns the same as operator<.

    + * + *

    This object determines the order of the elements in the container: it is a function pointer or a function + * object that takes two arguments of the same type as the container elements, and returns true if + * the first argument is considered to go before the second in the strict weak ordering it + * defines, and false otherwise.

    + * + *

    Two elements of a {@link ITreeSet} are considered equivalent if {@link key_comp} returns false + * reflexively (i.e., no matter the order in which the elements are passed as arguments).

    + * + *

    In {@link ITreeSet} containers, the keys to sort the elements are the values (T) themselves, + * therefore {@link key_comp} and its sibling member function {@link value_comp} are equivalent.

    + * + * @return The comparison function. + */ + value_comp(): (x: T, y: T) => boolean; + /** + * @inheritdoc + */ + is_equal_to(left: SetIterator, right: SetIterator): boolean; + /** + * @inheritdoc + */ + is_less(left: SetIterator, right: SetIterator): boolean; } } declare namespace std.base { From 5e27c7933424720b65d6680521bd74dafb236990 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 21 Jun 2016 16:11:12 +0900 Subject: [PATCH 3/4] Samchon-Framework-Tests --- samchon-framework/samchon-framework-tests.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/samchon-framework/samchon-framework-tests.ts b/samchon-framework/samchon-framework-tests.ts index 88c2632a37..59422caeea 100644 --- a/samchon-framework/samchon-framework-tests.ts +++ b/samchon-framework/samchon-framework-tests.ts @@ -1,4 +1,9 @@ /// import samchon = require("samchon-framework"); -console.log(samchon); \ No newline at end of file + +let xml = new samchon.library.XML(); +xml.setTag("font"); +xml.setProperty("fontSize", "13"); + +console.log(xml.toString()); \ No newline at end of file From 7cbebb0f32dca424e12f394208ffd01ab59cb7c5 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 21 Jun 2016 16:44:04 +0900 Subject: [PATCH 4/4] IEntityGroup.find has deprecated ES6 has Array.find method. --- samchon-framework/samchon-framework-tests.ts | 7 +------ samchon-framework/samchon-framework.d.ts | 19 ++++++------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/samchon-framework/samchon-framework-tests.ts b/samchon-framework/samchon-framework-tests.ts index 59422caeea..88c2632a37 100644 --- a/samchon-framework/samchon-framework-tests.ts +++ b/samchon-framework/samchon-framework-tests.ts @@ -1,9 +1,4 @@ /// import samchon = require("samchon-framework"); - -let xml = new samchon.library.XML(); -xml.setTag("font"); -xml.setProperty("fontSize", "13"); - -console.log(xml.toString()); \ No newline at end of file +console.log(samchon); \ No newline at end of file diff --git a/samchon-framework/samchon-framework.d.ts b/samchon-framework/samchon-framework.d.ts index 5a885d6cd1..c81a9d1e5b 100644 --- a/samchon-framework/samchon-framework.d.ts +++ b/samchon-framework/samchon-framework.d.ts @@ -2277,24 +2277,24 @@ declare namespace samchon.protocol { * *

    Standard Usage.

    * - * + * * * - * + * * * *

    Non-standard usage abusing value.

    * - * + * * jhnam88 * Jeongho Nam * 1988-03-11 - * - * + * + * * master * Administartor * 2011-07-28 - * + * * * * @return An XML object representing the Entity. @@ -2385,7 +2385,6 @@ declare namespace samchon.protocol { * @return An iterator to the element, if an element with specified key is found, or * {@link end end()} otherwise. */ - find(key: any): std.Iterator; /** *

    Whether have the item or not.

    * @@ -2455,7 +2454,6 @@ declare namespace samchon.protocol { /** * @inheritdoc */ - find(key: any): std.VectorIterator; /** * @inheritdoc */ @@ -2500,7 +2498,6 @@ declare namespace samchon.protocol { /** * @inheritdoc */ - find(key: any): std.ListIterator; /** * @inheritdoc */ @@ -2545,7 +2542,6 @@ declare namespace samchon.protocol { /** * @inheritdoc */ - find(key: any): std.DequeIterator; /** * @inheritdoc */ @@ -2597,7 +2593,6 @@ declare namespace samchon.protocol { /** * @inheritdoc */ - find(key: any): std.VectorIterator; /** * @inheritdoc */ @@ -2642,7 +2637,6 @@ declare namespace samchon.protocol { /** * @inheritdoc */ - find(key: any): std.ListIterator; /** * @inheritdoc */ @@ -2687,7 +2681,6 @@ declare namespace samchon.protocol { /** * @inheritdoc */ - find(key: any): std.DequeIterator; /** * @inheritdoc */

This namespace declares an unspecified number of objects: _1, _2, _3, ..., which are + * used to specify placeholders in calls to function {@link std.bind}.