UNPKG

declarations

Version:

[![npm version](https://badge.fury.io/js/declarations.svg)](https://www.npmjs.com/package/declarations)

762 lines (760 loc) 629 kB
// Type definitions for TypeScript-STL v1.0.8 // Project: https://github.com/samchon/typescript-stl // Definitions by: Jeongho Nam <http://samchon.org> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "typescript-stl" { export = std; } /** * <h1> TypeScript-STL </h1> * <p> <a href="https://nodei.co/npm/typescript-stl"> * <img src="https://nodei.co/npm/typescript-stl.png?downloads=true&downloadRank=true&stars=true"> </a> </p> * * <p> STL (Standard Template Library) Containers and Algorithms for TypeScript. </p> * * <p> TypeScript-STL is a TypeScript's <b>Standard Template Library</b> who is migrated from C++ STL. Most of classes * and functions of STL have implemented. Just enjoy it. </p> * * @git https://github.com/samchon/typescript-stl * @author Jeongho Nam <http://samchon.org> */ declare namespace std { /** * Type definition of {@link Vector} and it's the original name used in C++. */ export import vector = Vector; /** * Type definition of {@link List} and it's the original name used in C++. */ export import list = List; /** * Type definition of {@link Deque} and it's the original name used in C++. */ export import deque = Deque; /** * Type definition of {@link Stack} and it's the original name used in C++. */ type stack<T> = Stack<T>; /** * Type definition of {@link Queue} and it's the original name used in C++. */ type queue<T> = Queue<T>; /** * Type definition of {@link PriorityQueue} and it's the original name used in C++. */ type priority_queue<T> = PriorityQueue<T>; var stack: typeof Stack; var queue: typeof Queue; var priority_queue: typeof PriorityQueue; /** * Type definition of {@link TreeSet} and it's the original name used in C++. */ export import set = TreeSet; /** * Type definition of {@link TreeMultiSet} and it's the original name used in C++. */ export import multiset = TreeMultiSet; /** * Type definition of {@link HashSet} and it's the original name used in C++. */ export import unordered_set = HashSet; /** * Type definition of {@link HashMultiSet} and it's the original name used in C++. */ export import unordered_multiset = HashMultiSet; /** * Type definition of {@link TreeMap} and it's the original name used in C++. */ export import map = TreeMap; /** * Type definition of {@link TreeMultiMap} and it's the original name used in C++. */ export import multimap = TreeMultiMap; /** * Type definition of {@link HashMap} and it's the original name used in C++. */ export import unordered_map = HashMap; /** * Type definition of {@link HashMultiMap} and it's the original name used in C++. */ export import unordered_multimap = HashMultiMap; type exception = Exception; type logic_error = LogicError; type domain_error = DomainError; type invalid_argument = InvalidArgument; type length_error = LengthError; type out_of_range = OutOfRange; type runtime_error = RuntimeError; type overflow_error = OverflowError; type underflow_error = UnderflowError; type range_error = RangeError; type system_error = SystemError; type error_category = ErrorCategory; type error_condition = ErrorCondition; type error_code = ErrorCode; var exception: typeof Exception; var logic_error: typeof LogicError; var domain_error: typeof DomainError; var invalid_argument: typeof InvalidArgument; var length_error: typeof LengthError; var out_of_range: typeof OutOfRange; var runtime_error: typeof RuntimeError; var overflow_error: typeof OverflowError; var underflow_error: typeof UnderflowError; var range_error: typeof RangeError; var system_error: typeof SystemError; var error_category: typeof ErrorCategory; var error_condition: typeof ErrorCondition; var error_code: typeof ErrorCode; } /** * Base classes composing STL in background. * * @author Jeongho Nam <http://samchon.org> */ declare namespace std.base { } declare namespace std { /** * <p> Apply function to range. </p> * * <p> Applies function <i>fn</i> to each of the elements in the range [<i>first</i>, <i>last</i>). </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @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 <i>fn</i>. */ function for_each<T, InputIterator extends Iterator<T>, Func extends (val: T) => any>(first: InputIterator, last: InputIterator, fn: Func): Func; /** * <p> Test condition on all elements in range. </p> * * <p> Returns <code>true</code> if <i>pred</i> returns <code>true</code> for all the elements in the range * [<i>first</i>, <i>last</i>) or if the range is {@link IContainer.empty empty}, and <code>false</code> otherwise. * </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to * <code>boolean</code>. The value returned indicates whether the element fulfills the condition * checked by this function. The function shall not modify its argument. * * @return <code>true</code> if pred returns true for all the elements in the range or if the range is * {@link IContainer.empty empty}, and <code>false</code> otherwise. */ function all_of<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; /** * <p> Test if any element in range fulfills condition. </p> * * <p> Returns <code>true</code> if <i>pred</i> returns true for any of the elements in the range * [<i>first</i>, <i>last</i>), and <code>false</code> otherwise. </p> * * <p> If [<i>first</i>, <i>last</i>) is an {@link IContainer.empty empty} range, the function returns * <code>false</code>. </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to * <code>boolean</code>. The value returned indicates whether the element fulfills the condition * checked by this function. The function shall not modify its argument. * * @return <code>true</code> if <i>pred</i> returns <code>true</code> for any of the elements in the range * [<i>first</i>, <i>last</i>), and <code>false</code> otherwise. If [<i>first</i>, <i>last</i>) is an * {@link IContainer.empty empty} range, the function returns <code>false</code>. */ function any_of<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; /** * <p> Test if no elements fulfill condition. </p> * * <p> Returns <code>true</code> if <i>pred</i> returns false for all the elements in the range * [<i>first</i>, <i>last</i>) or if the range is {@link IContainer.empty empty}, and <code>false</code> otherwise. * </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to * <code>boolean</code>. The value returned indicates whether the element fulfills the condition * checked by this function. The function shall not modify its argument. * * @return <code>true</code> if <i>pred</i> returns <code>false</code> for all the elements in the range * [<i>first</i>, <i>last</i>) or if the range is {@link IContainer.empty empty}, and <code>false</code> * otherwise. */ function none_of<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): boolean; /** * <p> Test whether the elements in two ranges are equal. </p> * * <p> Compares the elements in the range [<i>first1</i>, <i>last1</i>) with those in the range beginning at * <i>first2</i>, and returns <code>true</code> if all of the elements in both ranges match. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first1</i>, <i>last1</i>). * * @return <code>true</code> if all the elements in the range [<i>first1</i>, <i>last1</i>) compare equal to those * of the range starting at <i>first2</i>, and <code>false</code> otherwise. */ function equal<T, Iterator1 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator<T>): boolean; /** * <p> Test whether the elements in two ranges are equal. </p> * * <p> Compares the elements in the range [<i>first1</i>, <i>last1</i>) with those in the range beginning at * <i>first2</i>, and returns <code>true</code> if all of the elements in both ranges match. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first1</i>, <i>last1</i>). * @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 <code>bool</code>. The value returned indicates whether * the elements are considered to match in the context of this function. * * @return <code>true</code> if all the elements in the range [<i>first1</i>, <i>last1</i>) compare equal to those * of the range starting at <i>first2</i>, and <code>false</code> otherwise. */ function equal<T, Iterator1 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator<T>, pred: (x: T, y: T) => boolean): boolean; /** * <p> Test whether range is permutation of another. </p> * * <p> Compares the elements in the range [<i>first1</i>, <i>last1</i>) with those in the range beginning at * <i>first2</i>, and returns <code>true</code> if all of the elements in both ranges match, even in a different * order. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first1</i>, <i>last1</i>). * * @return <code>true</code> if all the elements in the range [<i>first1</i>, <i>last1</i>) compare equal to those * of the range starting at <i>first2</i> in any order, and <code>false</code> otherwise. */ function is_permutation<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2): boolean; /** * <p> Test whether range is permutation of another. </p> * * <p> Compares the elements in the range [<i>first1</i>, <i>last1</i>) with those in the range beginning at * <i>first2</i>, and returns <code>true</code> if all of the elements in both ranges match, even in a different * order. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first1</i>, <i>last1</i>). * @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 <code>bool</code>. The value returned indicates whether * the elements are considered to match in the context of this function. * * @return <code>true</code> if all the elements in the range [<i>first1</i>, <i>last1</i>) compare equal to those * of the range starting at <i>first2</i> in any order, and <code>false</code> otherwise. */ function is_permutation<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, pred: (x: T, y: T) => boolean): boolean; /** * <p> Lexicographical less-than comparison. </p> * * <p> Returns <code>true</code> if the range [<i>first1</i>, <i>last1</i>) compares <i>lexicographically less</i> * than the range [<i>first2</i>, <i>last2</i>). </p> * * <p> A <i>lexicographical comparison</i> 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. </p> * * <p> If both sequences compare equal until one of them ends, the shorter sequence is <i>lexicographically less</i> * than the longer one. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 * [<i>first2</i>, <i>last2</i>). * * @return <code>true</code> if the first range compares <i>lexicographically less</i> than than the second. * <code>false</code> otherwise (including when all the elements of both ranges are equivalent). */ function lexicographical_compare<T, T1 extends T, T2 extends T, Iterator1 extends Iterator<T1>, Iterator2 extends Iterator<T2>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): boolean; /** * <p> Lexicographical comparison. </p> * * <p> Returns <code>true</code> if the range [<i>first1</i>, <i>last1</i>) compares <i>lexicographically * relationship</i> than the range [<i>first2</i>, <i>last2</i>). </p> * * <p> A <i>lexicographical comparison</i> 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. </p> * * <p> If both sequences compare equal until one of them ends, the shorter sequence is <i>lexicographically * relationship</i> than the longer one. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 * [<i>first2</i>, <i>last2</i>). * @param compare Binary function that accepts two arguments of the types pointed by the iterators, and returns a * value convertible to <code>bool</code>. The value returned indicates whether the first argument is * considered to go before the second in the specific <i>strict weak ordering</i> it defines. * * @return <code>true</code> if the first range compares <i>lexicographically relationship</i> than than the * second. <code>false</code> otherwise (including when all the elements of both ranges are equivalent). */ function lexicographical_compare<T, T1 extends T, T2 extends T, Iterator1 extends Iterator<T1>, Iterator2 extends Iterator<T2>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, compare: (x: T, y: T) => boolean): boolean; /** * <p> Find value in range. </p> * * <p> Returns an iterator to the first element in the range [<i>first</i>, <i>last</i>) that compares equal to * <i>val</i>. If no such element is found, the function returns <i>last</i>. </p> * * <p> The function uses {@link equal_to equal_to} to compare the individual elements to <i>val</i>. </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param val Value to search for in the range. * * @return An {@link Iterator} to the first element in the range that compares equal to <i>val</i>. If no elements * match, the function returns <i>last</i>. */ function find<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, val: T): InputIterator; /** * <p> Find element in range. </p> * * <p> Returns an iterator to the first element in the range [<i>first</i>, <i>last</i>) for which pred returns * <code>true</code>. If no such element is found, the function returns <i>last</i>. </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param pred Unary function that accepts an element in the range as argument and returns a value convertible * to <code>bool</code>. 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 <i>pred</i> does not return * <code>false</code>. If <i>pred</i> is <code>false</code> for all elements, the function returns * <i>last</i>. */ function find_if<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): InputIterator; /** * <p> Find element in range. </p> * * <p> Returns an iterator to the first element in the range [<i>first</i>, <i>last</i>) for which pred returns * <code>true</code>. If no such element is found, the function returns <i>last</i>. </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param pred Unary function that accepts an element in the range as argument and returns a value convertible * to <code>bool</code>. 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 <i>pred</i> returns <code>false</code>. * If <i>pred</i> is <code>true</code> for all elements, the function returns <i>last</i>. */ function find_if_not<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): InputIterator; /** * <p> Find last subsequence in range. </p> * * <p> Searches the range [<i>first1</i>, <i>last1</i>) for the last occurrence of the sequence defined by * [<i>first2</i>, <i>last2</i>), and returns an {@link Iterator} to its first element, or <i>last1,/i> if no * occurrences are found. </p> * * <p> The elements in both ranges are compared sequentially using {@link equal_to}: A subsequence of * [<i>first1</i>, <i>last1</i>) is considered a match only when this is <code>true</code> for all the elements of * [<i>first2</i>, <i>last2</i>). </p> * * <p> This function returns the last of such occurrences. For an algorithm that returns the first instead, see * {@link search}. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first2</i>, <i>last2</i>). * @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 <code>bool</code>. 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 [<i>first2</i>, <i>last2</i>) in * [<i>first1</i>, <i>last1</i>). If the sequence is not found, the function returns ,i>last1</i>. Otherwise * [<i>first2</i>, <i>last2</i>) is an empty range, the function returns <i>last1</i>. */ function find_end<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): Iterator1; /** * <p> Find last subsequence in range. </p> * * <p> Searches the range [<i>first1</i>, <i>last1</i>) for the last occurrence of the sequence defined by * [<i>first2</i>, <i>last2</i>), and returns an {@link Iterator} to its first element, or <i>last1,/i> if no * occurrences are found. </p> * * <p> The elements in both ranges are compared sequentially using <i>pred</i>: A subsequence of * [<i>first1</i>, <i>last1</i>) is considered a match only when this is <code>true</code> for all the elements of * [<i>first2</i>, <i>last2</i>). </p> * * <p> This function returns the last of such occurrences. For an algorithm that returns the first instead, see * {@link search}. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first2</i>, <i>last2</i>). * @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 <code>bool</code>. 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 [<i>first2</i>, <i>last2</i>) in * [<i>first1</i>, <i>last1</i>). If the sequence is not found, the function returns ,i>last1</i>. Otherwise * [<i>first2</i>, <i>last2</i>) is an empty range, the function returns <i>last1</i>. */ function find_end<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, pred: (x: T, y: T) => boolean): Iterator1; /** * <p> Find element from set in range. </p> * * <p> Returns an iterator to the first element in the range [<i>first1</i>, <i>last1</i>) that matches any of the * elements in [<i>first2</i>, <i>last2</i>). If no such element is found, the function returns <i>last1</i>. </p> * * <p> The elements in [<i>first1</i>, <i>last1</i>) are sequentially compared to each of the values in * [<i>first2</i>, <i>last2</i>) using {@link equal_to}, until a pair matches. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first2</i>, <i>last2</i>). * * @return An {@link Iterator} to the first element in [<i>first1</i>, <i>last1</i>) that is part of * [<i>first2</i>, <i>last2</i>). If no matches are found, the function returns <i>last1</i>. */ function find_first_of<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2): Iterator1; /** * <p> Find element from set in range. </p> * * <p> Returns an iterator to the first element in the range [<i>first1</i>, <i>last1</i>) that matches any of the * elements in [<i>first2</i>, <i>last2</i>). If no such element is found, the function returns <i>last1</i>. </p> * * <p> The elements in [<i>first1</i>, <i>last1</i>) are sequentially compared to each of the values in * [<i>first2</i>, <i>last2</i>) using <i>pred</i>, until a pair matches. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first2</i>, <i>last2</i>). * @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 <code>bool</code>. 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 [<i>first1</i>, <i>last1</i>) that is part of * [<i>first2</i>, <i>last2</i>). If no matches are found, the function returns <i>last1</i>. */ function find_first_of<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, last2: Iterator2, pred: (x: T, y: T) => boolean): Iterator1; /** * <p> Find equal adjacent elements in range. </p> * * <p> Searches the range [<i>first</i>, <i>last</i>) for the first occurrence of two consecutive elements that match, * and returns an {@link Iterator} to the first of these two elements, or <i>last</i> if no such pair is found. </p> * * <p> Two elements match if they compare equal using {@link equal_to}. </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * * @return An {@link Iterator} to the first element of the first pair of matching consecutive elements in the range * [<i>first</i>, <i>last</i>). If no such pair is found, the function returns <i>last</i>. */ function adjacent_find<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator): InputIterator; /** * <p> Find equal adjacent elements in range. </p> * * <p> Searches the range [<i>first</i>, <i>last</i>) for the first occurrence of two consecutive elements that match, * and returns an {@link Iterator} to the first of these two elements, or <i>last</i> if no such pair is found. </p> * * <p> Two elements match if they compare equal using <i>pred</i>. </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param pred Unary function that accepts an element in the range as argument and returns a value convertible to * <code>bool</code>. 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 * [<i>first</i>, <i>last</i>). If no such pair is found, the function returns <i>last</i>. */ function adjacent_find<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, pred: (x: T, y: T) => boolean): InputIterator; /** * <p> Search range for subsequence. </p> * * <p> Searches the range [<i>first1</i>, <i>last1</i>) for the first occurrence of the sequence defined by * [<i>first2</i>, <i>last2</i>), and returns an iterator to its first element, or <i>last1</i> if no occurrences are * found. </p> * * <p> The elements in both ranges are compared sequentially using {@link equal_to}: A subsequence of * [<i>first1</i>, <i>last1</i>) is considered a match only when this is true for <b>all</b> the elements of * [<i>first2</i>, <i>last2</i>). </p> * * <p> This function returns the first of such occurrences. For an algorithm that returns the last instead, see * {@link find_end}. </p> * * @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 * [<i>first1</i>, <i>last1</i>), which contains all the elements between <i>first1</i> and <i>last1</i>, * including the element pointed by <i>first1</i> but not the element pointed by <i>last1</i>. * @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 [<i>first2</i>, <i>last2</i>). * * @return An iterator to the first element of the first occurrence of [<i>first2</i>, <i>last2</i>) in <i>first1</i> * and <i>last1</i>. If the sequence is not found, the function returns <i>last1</i>. Otherwise * [<i>first2</i>, <i>last2</i>) is an empty range, the function returns <i>first1</i>. */ function search<T, ForwardIterator1 extends Iterator<T>, ForwardIterator2 extends Iterator<T>>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2, last2: ForwardIterator2): ForwardIterator1; /** * <p> Search range for subsequence. </p> * * <p> Searches the range [<i>first1</i>, <i>last1</i>) for the first occurrence of the sequence defined by * [<i>first2</i>, <i>last2</i>), and returns an iterator to its first element, or <i>last1</i> if no occurrences are * found. </p> * * <p> The elements in both ranges are compared sequentially using <i>pred</i>: A subsequence of * [<i>first1</i>, <i>last1</i>) is considered a match only when this is true for <b>all</b> the elements of * [<i>first2</i>, <i>last2</i>). </p> * * <p> This function returns the first of such occurrences. For an algorithm that returns the last instead, see * {@link find_end}. </p> * * @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 * [<i>first1</i>, <i>last1</i>), which contains all the elements between <i>first1</i> and <i>last1</i>, * including the element pointed by <i>first1</i> but not the element pointed by <i>last1</i>. * @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 [<i>first2</i>, <i>last2</i>). * @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 [<i>first2</i>, <i>last2</i>) in * [<i>first1</i>, <i>last1</i>). If the sequence is not found, the function returns last1. Otherwise * [<i>first2</i>, <i>last2</i>) is an empty range, the function returns <i>first1</i>. */ function search<T, ForwardIterator1 extends Iterator<T>, ForwardIterator2 extends Iterator<T>>(first1: ForwardIterator1, last1: ForwardIterator1, first2: ForwardIterator2, last2: ForwardIterator2, pred: (x: T, y: T) => boolean): ForwardIterator1; /** * <p> Search range for elements. </p> * * <p> Searches the range [<i>first</i>, <i>last</i>) for a sequence of <i>count</i> elements, each comparing equal to * <i>val</i>. </p> * * <p> The function returns an iterator to the first of such elements, or <i>last</i> if no such sequence is found. * </p> * * @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 * [<i>first</i>, <i>last</i>), which contains all the elements between <i>first</i> and <i>last</i>, * including the element pointed by <i>first</i> but not the element pointed by <i>last</i>. * @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 * <i>last</i>. */ function search_n<T, ForwardIterator extends base.IArrayIterator<T>>(first: ForwardIterator, last: ForwardIterator, count: number, val: T): ForwardIterator; /** * <p> Search range for elements. </p> * * <p> Searches the range [<i>first</i>, <i>last</i>) for a sequence of <i>count</i> elements, each comparing equal to * <i>val</i>. </p> * * <p> The function returns an iterator to the first of such elements, or <i>last</i> if no such sequence is found. * </p> * * @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 * [<i>first</i>, <i>last</i>), which contains all the elements between <i>first</i> and <i>last</i>, * including the element pointed by <i>first</i> but not the element pointed by <i>last</i>. * @param count Minimum number of successive elements to match. * @param val Individual value to be compared, or to be used as argument for <i>pred</i>. * @param pred Binary function that accepts two arguments (one element from the sequence as first, and <i>val</i> as * second), and returns a value convertible to <code>bool</code>. 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 <i>last</i>. */ function search_n<T, ForwardIterator extends base.IArrayIterator<T>>(first: ForwardIterator, last: ForwardIterator, count: number, val: T, pred: (x: T, y: T) => boolean): ForwardIterator; /** * <p> Return first position where two ranges differ. </p> * * <p> Compares the elements in the range [<i>first1</i>, <i>last1</i>) with those in the range beginning at * <i>first2</i>, and returns the first element of both sequences that does not match. </p> * * <p> The function returns a {@link Pair} of {@link iterators Iterator} to the first element in each range that * does not match. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first1</i>, <i>last1</i>). * * @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 <i>last1</i> 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}(<i>first1</i>, <i>first2</i>). */ function mismatch<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2): Pair<Iterator1, Iterator2>; /** * <p> Return first position where two ranges differ. </p> * * <p> Compares the elements in the range [<i>first1</i>, <i>last1</i>) with those in the range beginning at * <i>first2</i>, and returns the first element of both sequences that does not match. </p> * * <p> The function returns a {@link Pair} of {@link iterators Iterator} to the first element in each range that * does not match. </p> * * @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 * [<i>first1</i>, <i>last1</i>), including the element pointed by <i>first1</i>, but not the element * pointed by <i>last1</i>. * @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 [<i>first1</i>, <i>last1</i>). * @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 <code>bool</code>. 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 <i>last1</i> 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}(<i>first1</i>, <i>first2</i>). */ function mismatch<T, Iterator1 extends Iterator<T>, Iterator2 extends Iterator<T>>(first1: Iterator1, last1: Iterator1, first2: Iterator2, compare: (x: T, y: T) => boolean): Pair<Iterator1, Iterator2>; /** * <p> Count appearances of value in range. </p> * * <p> Returns the number of elements in the range [<i>first</i>, <i>last</i>) that compare equal to <i>val</i>. </p> * * <p> The function uses {@link equal_to} to compare the individual elements to <i>val</i>. </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param val Value to match. * * @return The number of elements in the range [<i>first</i>, <i>last</i>) that compare equal to <i>val</i>. */ function count<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, val: T): number; /** * <p> Return number of elements in range satisfying condition. </p> * * <p> Returns the number of elements in the range [<i>first</i>, <i>last</i>) for which pred is <code>true</code>. * </p> * * @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 [<i>first</i>, <i>last</i>), * which contains all the elements between <i>first</i> and <i>last</i>, including the element pointed by * <i>first</i> but not the element pointed by <i>last</i>. * @param pred Unary function that accepts an element in the range as argument, and returns a value convertible * to <code>bool</code>. 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<T, InputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, pred: (val: T) => boolean): number; } declare namespace std { /** * <p> Copy range of elements. </p> * * <p> Copies the elements in the range [<i>first</i>, <i>last</i>) into the range beginning at <i>result</i>. </p> * * <p> The function returns an iterator to the end of the destination range (which points to the element following the * last element copied). </p> * * <p> The ranges shall not overlap in such a way that result points to an element in the range * [<i>first</i>, <i>last</i>). For such cases, see {@link copy_backward}. </p> * * @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 * [<i>first</i>, <i>last</i>), which contains all the elements between <i>first</i> and <i>last</i>, * including the element pointed by <i>first</i> but not the element pointed by <i>last</i>. * @param result {@link Iterator Output iterator} to the initial position in the destination sequence. This shall not * point to any element in the range [<i>first</i>, <i>last</i>). * * @return An iterator to the end of the destination range where elements have been copied. */ function copy<T, InputIterator extends Iterator<T>, OutputIterator extends Iterator<T>>(first: InputIterator, last: InputIterator, result: OutputIterator): OutputIterator; /** * <p> Copy elements. </p> * * <p> Copies the first <i>n</i> elements from the range beginning at <i>first</i> into the range beginning at * <i>result</i>. </p> * * <p> The function returns an iterator to the end of the destination range (which points to one past the last element * copied). </p> * * <p> If <i>n</i> is negative, the function does nothing. </p> * * <p> If the ranges overlap, some of the elements in the range pointed by result may have undefined but valid values. * </p> * * @param first {@link Iterator Input iterator} to the initial position in a sequence of at least <i>n</i> elements to * be copied. <i>InputIterator</i> shall point to a type assignable to the elements pointed by * <i>OutputIterator</i>. * @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 * <i>n</i> elements. This shall not point to any element in the range [<i>first</i>, last]. * * @return An iterator to the end of the destination range where elements have been copied. */ function copy_n<T, InputIterator extends Iterator<T>, OutputIterator extends Iterator<T>>(first: InputIterator, n: number, result: OutputIterator): OutputIterator; /** * <p> Copy certain elements of range. </p> * * <p> Copies the elements in the range [<i>first</i>, <i>last</i>) for which pred returns <code>true</code> to the * range beginning at <i>result</i>. </p> * * @param first {@link Iterator Input iterator} to the initial position in a sequence to be copied. * @param last {@link Iterator Input iterator} to the initi