include node_modules so release .zip is deployable

This commit is contained in:
2023-11-24 17:44:25 -05:00
parent 6c86cfe5d2
commit 8b11c41267
8963 changed files with 874175 additions and 1 deletions
+43
View File
@@ -0,0 +1,43 @@
import { IForwardContainer } from "../container/IForwardContainer";
import { Pair } from "../../utility/Pair";
import { Comparator } from "../../internal/functional/Comparator";
/**
* Get iterator to lower bound.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element equal or after the val.
*/
export declare function lower_bound<Range extends Array<any> | IForwardContainer<any>>(range: Range, val: IForwardContainer.ValueType<Range>, comp?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Get iterator to upper bound.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element after the key.
*/
export declare function upper_bound<Range extends Array<any> | IForwardContainer<any>>(range: Range, val: IForwardContainer.ValueType<Range>, comp?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Get range of equal elements.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Pair of {@link lower_bound} and {@link upper_bound}.
*/
export declare function equal_range<Range extends Array<any> | IForwardContainer<any>>(range: Range, val: IForwardContainer.ValueType<Range>, comp?: Comparator<IForwardContainer.ValueType<Range>>): Pair<IForwardContainer.IteratorType<Range>, IForwardContainer.IteratorType<Range>>;
/**
* Test whether a value exists in sorted range.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the value exists or not.
*/
export declare function binary_search<Range extends Array<any> | IForwardContainer<any>>(range: Range, val: IForwardContainer.ValueType<Range>, comp?: Comparator<IForwardContainer.ValueType<Range>>): boolean;
+95
View File
@@ -0,0 +1,95 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.binary_search = exports.equal_range = exports.upper_bound = exports.lower_bound = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/binary_search"));
var factory_1 = require("../../iterator/factory");
var comparators_1 = require("../../functional/comparators");
/* =========================================================
BINARY SEARCH
========================================================= */
/**
* Get iterator to lower bound.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element equal or after the val.
*/
function lower_bound(range, val, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.lower_bound((0, factory_1.begin)(range), (0, factory_1.end)(range), val, comp);
}
exports.lower_bound = lower_bound;
/**
* Get iterator to upper bound.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element after the key.
*/
function upper_bound(range, val, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.upper_bound((0, factory_1.begin)(range), (0, factory_1.end)(range), val, comp);
}
exports.upper_bound = upper_bound;
/**
* Get range of equal elements.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Pair of {@link lower_bound} and {@link upper_bound}.
*/
function equal_range(range, val, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.equal_range((0, factory_1.begin)(range), (0, factory_1.end)(range), val, comp);
}
exports.equal_range = equal_range;
/**
* Test whether a value exists in sorted range.
*
* @param range An iterable ranged container.
* @param val Value to search for.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the value exists or not.
*/
function binary_search(range, val, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.binary_search((0, factory_1.begin)(range), (0, factory_1.end)(range), val, comp);
}
exports.binary_search = binary_search;
//# sourceMappingURL=binary_search.js.map
+48
View File
@@ -0,0 +1,48 @@
import { IRandomAccessContainer } from "../container/IRandomAccessContainer";
import { Comparator } from "../../internal/functional/Comparator";
/**
* Make a heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function make_heap<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IRandomAccessContainer.ValueType<Range>>): void;
/**
* Push an element into heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function push_heap<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IRandomAccessContainer.ValueType<Range>>): void;
/**
* Pop an element from heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function pop_heap<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IRandomAccessContainer.ValueType<Range>>): void;
/**
* Test whether a range is heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the range is heap.
*/
export declare function is_heap<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IRandomAccessContainer.ValueType<Range>>): boolean;
/**
* Find the first element not in heap order.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element not in heap order.
*/
export declare function is_heap_until<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IRandomAccessContainer.ValueType<Range>>): IRandomAccessContainer.IteratorType<Range>;
/**
* Sort elements of a heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function sort_heap<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IRandomAccessContainer.ValueType<Range>>): void;
+112
View File
@@ -0,0 +1,112 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sort_heap = exports.is_heap_until = exports.is_heap = exports.pop_heap = exports.push_heap = exports.make_heap = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/heap"));
var factory_1 = require("../../iterator/factory");
var comparators_1 = require("../../functional/comparators");
/* ---------------------------------------------------------
PUSH & POP
--------------------------------------------------------- */
/**
* Make a heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function make_heap(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.make_heap((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.make_heap = make_heap;
/**
* Push an element into heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function push_heap(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.push_heap((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.push_heap = push_heap;
/**
* Pop an element from heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function pop_heap(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.pop_heap((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.pop_heap = pop_heap;
/* ---------------------------------------------------------
SORT
--------------------------------------------------------- */
/**
* Test whether a range is heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the range is heap.
*/
function is_heap(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.is_heap((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.is_heap = is_heap;
/**
* Find the first element not in heap order.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element not in heap order.
*/
function is_heap_until(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.is_heap_until((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.is_heap_until = is_heap_until;
/**
* Sort elements of a heap.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function sort_heap(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.sort_heap((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.sort_heap = sort_heap;
//# sourceMappingURL=heap.js.map
+13
View File
@@ -0,0 +1,13 @@
/**
* @packageDocumentation
* @module std.ranges
*/
export * from "./binary_search";
export * from "./heap";
export * from "./iterations";
export * from "./mathematics";
export * from "./modifiers";
export * from "./partition";
export * from "./random";
export * from "./sorting";
export * from "./merge";
+32
View File
@@ -0,0 +1,32 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
__exportStar(require("./binary_search"), exports);
__exportStar(require("./heap"), exports);
__exportStar(require("./iterations"), exports);
__exportStar(require("./mathematics"), exports);
__exportStar(require("./modifiers"), exports);
__exportStar(require("./partition"), exports);
__exportStar(require("./random"), exports);
__exportStar(require("./sorting"), exports);
__exportStar(require("./merge"), exports);
//# sourceMappingURL=index.js.map
+224
View File
@@ -0,0 +1,224 @@
import { IForwardContainer } from "../container/IForwardContainer";
import { Pair } from "../../utility/Pair";
import { UnaryPredicator } from "../../internal/functional/UnaryPredicator";
import { BinaryPredicator } from "../../internal/functional/BinaryPredicator";
import { Comparator } from "../../internal/functional/Comparator";
declare type BinaryPredicatorInferrer<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>> = BinaryPredicator<IForwardContainer.ValueType<Range1>, IForwardContainer.ValueType<Range2>>;
/**
* Apply a function to elements in range.
*
* @param range An iterable ranged container.
* @param fn The function to apply.
*
* @return The function *fn* itself.
*/
export declare function for_each<Range extends Array<any> | IForwardContainer<any>, Func extends (val: IForwardContainer.ValueType<Range>) => any>(range: Range, fn: Func): Func;
/**
* Apply a function to elements in steps.
*
* @param range An iterable ranged container.
* @param n Steps to maximum advance.
* @param fn The function to apply.
*
* @return Iterator advanced from *first* for *n* steps.
*/
export declare function for_each_n<Range extends Array<any> | IForwardContainer<any>, Func extends (val: IForwardContainer.ValueType<Range>) => any>(range: Range, n: number, fn: Func): IForwardContainer.IteratorType<Range>;
/**
* Test whether all elements meet a specific condition.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Whether the *pred* returns always `true` for all elements.
*/
export declare function all_of<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): boolean;
/**
* Test whether any element meets a specific condition.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Whether the *pred* returns at least a `true` for all elements.
*/
export declare function any_of<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): boolean;
/**
* Test whether any element doesn't meet a specific condition.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Whether the *pred* doesn't return `true` for all elements.
*/
export declare function none_of<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): boolean;
/**
* Test whether two ranges are equal.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal.
*
* @return Whether two ranges are equal.
*/
export declare function equal<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2): boolean;
/**
* Test whether two ranges are equal.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal.
*
* @return Whether two ranges are equal.
*/
export declare function equal<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>>(range1: Range1, range2: Range2, pred: BinaryPredicatorInferrer<Range1, Range2>): boolean;
/**
* Compare lexicographically.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the 1st range precedes the 2nd.
*/
export declare function lexicographical_compare<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2, comp?: BinaryPredicatorInferrer<Range1, Range1>): boolean;
/**
* Find a value in range.
*
* @param range An iterable ranged container.
* @param val The value to find.
*
* @return Iterator to the first element {@link equal to equal_to} the value.
*/
export declare function find<Range extends Array<any> | IForwardContainer<any>>(range: Range, val: IForwardContainer.ValueType<Range>): IForwardContainer.IteratorType<Range>;
/**
* Find a matched condition in range.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Iterator to the first element *pred* returns `true`.
*/
export declare function find_if<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Find a mismatched condition in range.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Iterator to the first element *pred* returns `false`.
*/
export declare function find_if_not<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Find the last sub range.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
*
* @return Iterator to the first element of the last sub range.
*/
export declare function find_end<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2): IForwardContainer.IteratorType<Range1>;
/**
* Find the last sub range.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal.
*
* @return Iterator to the first element of the last sub range.
*/
export declare function find_end<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>>(range1: Range1, range2: Range2, pred: BinaryPredicatorInferrer<Range1, Range2>): IForwardContainer.IteratorType<Range1>;
/**
* Find the first sub range.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
*
* @return Iterator to the first element of the first sub range.
*/
export declare function find_first_of<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2): IForwardContainer.IteratorType<Range1>;
/**
* Find the first sub range.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal.
*
* @return Iterator to the first element of the first sub range.
*/
export declare function find_first_of<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>>(range1: Range1, range2: Range2, pred: BinaryPredicatorInferrer<Range1, Range2>): IForwardContainer.IteratorType<Range1>;
/**
* Find the first adjacent element.
*
* @param range An iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Iterator to the first element of adjacent find.
*/
export declare function adjacent_find<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Search sub range.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
*
* @return Iterator to the first element of the sub range.
*/
export declare function search<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2): IForwardContainer.IteratorType<Range1>;
/**
* Search sub range.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal.
*
* @return Iterator to the first element of the sub range.
*/
export declare function search<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>>(range1: Range1, range2: Range2, pred: BinaryPredicatorInferrer<Range1, Range2>): IForwardContainer.IteratorType<Range1>;
/**
* Search specific and repeated elements.
*
* @param range An iterable ranged container.
* @param count Count to be repeated.
* @param val Value to search.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Iterator to the first element of the repetition.
*/
export declare function search_n<Range extends Array<any> | IForwardContainer<any>>(range: Range, count: number, val: IForwardContainer.ValueType<Range>, pred?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Find the first mistmached position between two ranges.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
*
* @return A {@link Pair} of mismatched positions.
*/
export declare function mismatch<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2): Pair<IForwardContainer.IteratorType<Range1>, IForwardContainer.IteratorType<Range2>>;
/**
* Find the first mistmached position between two ranges.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal.
*
* @return A {@link Pair} of mismatched positions.
*/
export declare function mismatch<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>>(range1: Range1, range2: Range2, pred: BinaryPredicatorInferrer<Range1, Range2>): Pair<IForwardContainer.IteratorType<Range1>, IForwardContainer.IteratorType<Range2>>;
/**
* Count matched value in range.
*
* @param range An iterable ranged container.
* @param val The value to count.
*
* @return The matched count.
*/
export declare function count<Range extends Array<any> | IForwardContainer<any>>(range: Range, val: IForwardContainer.ValueType<Range>): number;
/**
* Count matched condition in range.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return The matched count.
*/
export declare function count_if<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): number;
export {};
+252
View File
@@ -0,0 +1,252 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.count_if = exports.count = exports.mismatch = exports.search_n = exports.search = exports.adjacent_find = exports.find_first_of = exports.find_end = exports.find_if_not = exports.find_if = exports.find = exports.lexicographical_compare = exports.equal = exports.none_of = exports.any_of = exports.all_of = exports.for_each_n = exports.for_each = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/iterations"));
var Pair_1 = require("../../utility/Pair");
var factory_1 = require("../../iterator/factory");
var global_1 = require("../../iterator/global");
var comparators_1 = require("../../functional/comparators");
/* ---------------------------------------------------------
FOR_EACH
--------------------------------------------------------- */
/**
* Apply a function to elements in range.
*
* @param range An iterable ranged container.
* @param fn The function to apply.
*
* @return The function *fn* itself.
*/
function for_each(range, fn) {
return base.for_each((0, factory_1.begin)(range), (0, factory_1.end)(range), fn);
}
exports.for_each = for_each;
/**
* Apply a function to elements in steps.
*
* @param range An iterable ranged container.
* @param n Steps to maximum advance.
* @param fn The function to apply.
*
* @return Iterator advanced from *first* for *n* steps.
*/
function for_each_n(range, n, fn) {
return base.for_each_n((0, factory_1.begin)(range), n, fn);
}
exports.for_each_n = for_each_n;
/* ---------------------------------------------------------
AGGREGATE CONDITIONS
--------------------------------------------------------- */
/**
* Test whether all elements meet a specific condition.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Whether the *pred* returns always `true` for all elements.
*/
function all_of(range, pred) {
return base.all_of((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.all_of = all_of;
/**
* Test whether any element meets a specific condition.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Whether the *pred* returns at least a `true` for all elements.
*/
function any_of(range, pred) {
return base.any_of((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.any_of = any_of;
/**
* Test whether any element doesn't meet a specific condition.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Whether the *pred* doesn't return `true` for all elements.
*/
function none_of(range, pred) {
return base.none_of((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.none_of = none_of;
function equal(range1, range2, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
if ((0, global_1.size)(range1) !== (0, global_1.size)(range2))
return false;
else
return base.equal((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), pred);
}
exports.equal = equal;
/**
* Compare lexicographically.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the 1st range precedes the 2nd.
*/
function lexicographical_compare(range1, range2, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.lexicographical_compare((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), comp);
}
exports.lexicographical_compare = lexicographical_compare;
/* ---------------------------------------------------------
FINDERS
--------------------------------------------------------- */
/**
* Find a value in range.
*
* @param range An iterable ranged container.
* @param val The value to find.
*
* @return Iterator to the first element {@link equal to equal_to} the value.
*/
function find(range, val) {
return base.find((0, factory_1.begin)(range), (0, factory_1.end)(range), val);
}
exports.find = find;
/**
* Find a matched condition in range.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Iterator to the first element *pred* returns `true`.
*/
function find_if(range, pred) {
return base.find_if((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.find_if = find_if;
/**
* Find a mismatched condition in range.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return Iterator to the first element *pred* returns `false`.
*/
function find_if_not(range, pred) {
return base.find_if_not((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.find_if_not = find_if_not;
function find_end(range1, range2, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.find_end((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), pred);
}
exports.find_end = find_end;
function find_first_of(range1, range2, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.find_first_of((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), pred);
}
exports.find_first_of = find_first_of;
/**
* Find the first adjacent element.
*
* @param range An iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Iterator to the first element of adjacent find.
*/
function adjacent_find(range, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.adjacent_find((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.adjacent_find = adjacent_find;
function search(range1, range2, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.search((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), pred);
}
exports.search = search;
/**
* Search specific and repeated elements.
*
* @param range An iterable ranged container.
* @param count Count to be repeated.
* @param val Value to search.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Iterator to the first element of the repetition.
*/
function search_n(range, count, val, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.search_n((0, factory_1.begin)(range), (0, factory_1.end)(range), count, val, pred);
}
exports.search_n = search_n;
function mismatch(range1, range2, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
if ((0, global_1.size)(range1) === (0, global_1.size)(range2))
return base.mismatch((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), pred);
var limit = Math.min((0, global_1.size)(range1), (0, global_1.size)(range2));
var x = (0, factory_1.begin)(range1);
var y = (0, factory_1.begin)(range2);
for (var i = 0; i < limit; ++i) {
if (pred(x.value, y.value) === false)
break;
x = x.next();
y = y.next();
}
return new Pair_1.Pair(x, y);
}
exports.mismatch = mismatch;
/* ---------------------------------------------------------
COUNTERS
--------------------------------------------------------- */
/**
* Count matched value in range.
*
* @param range An iterable ranged container.
* @param val The value to count.
*
* @return The matched count.
*/
function count(range, val) {
return base.count((0, factory_1.begin)(range), (0, factory_1.end)(range), val);
}
exports.count = count;
/**
* Count matched condition in range.
*
* @param range An iterable ranged container.
* @param pred A function predicates the specific condition.
*
* @return The matched count.
*/
function count_if(range, pred) {
return base.count_if((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.count_if = count_if;
//# sourceMappingURL=iterations.js.map
+59
View File
@@ -0,0 +1,59 @@
import { IBidirectionalContainer } from "../container/IBidirectionalContainer";
import { IForwardContainer } from "../container/IForwardContainer";
import { Pair } from "../../utility/Pair";
import { Comparator } from "../../internal/functional/Comparator";
/**
* Get the minimum element in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the minimum element.
*/
export declare function min_element<Range extends Array<any> | IForwardContainer<any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Get the maximum element in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the maximum element.
*/
export declare function max_element<Range extends Array<any> | IForwardContainer<any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Get the minimum & maximum elements in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return A {@link Pair} of iterators to the minimum & maximum elements.
*/
export declare function minmax_element<Range extends Array<any> | IForwardContainer<any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): Pair<IForwardContainer.IteratorType<Range>, IForwardContainer.IteratorType<Range>>;
/**
* Test whether two ranges are in permutation relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Whether permutation or not.
*/
export declare function is_permutation<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2, pred?: Comparator<IForwardContainer.ValueType<Range1>>): boolean;
/**
* Transform to the previous permutation.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the transformation was meaningful.
*/
export declare function prev_permutation<Range extends Array<any> | IBidirectionalContainer<any, any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): boolean;
/**
* Transform to the next permutation.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the transformation was meaningful.
*/
export declare function next_permutation<Range extends Array<any> | IBidirectionalContainer<any, any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): boolean;
+125
View File
@@ -0,0 +1,125 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.next_permutation = exports.prev_permutation = exports.is_permutation = exports.minmax_element = exports.max_element = exports.min_element = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/mathematics"));
var comparators_1 = require("../../functional/comparators");
var factory_1 = require("../../iterator/factory");
var global_1 = require("../../iterator/global");
/* ---------------------------------------------------------
MIN & MAX
--------------------------------------------------------- */
/**
* Get the minimum element in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the minimum element.
*/
function min_element(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.min_element((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.min_element = min_element;
/**
* Get the maximum element in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the maximum element.
*/
function max_element(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.max_element((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.max_element = max_element;
/**
* Get the minimum & maximum elements in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return A {@link Pair} of iterators to the minimum & maximum elements.
*/
function minmax_element(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.minmax_element((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.minmax_element = minmax_element;
/* ---------------------------------------------------------
PERMUATATIONS
--------------------------------------------------------- */
/**
* Test whether two ranges are in permutation relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Whether permutation or not.
*/
function is_permutation(range1, range2, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
if ((0, global_1.size)(range1) !== (0, global_1.size)(range2))
return false;
else
return base.is_permutation((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), pred);
}
exports.is_permutation = is_permutation;
/**
* Transform to the previous permutation.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the transformation was meaningful.
*/
function prev_permutation(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.prev_permutation((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.prev_permutation = prev_permutation;
/**
* Transform to the next permutation.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether the transformation was meaningful.
*/
function next_permutation(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.next_permutation((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.next_permutation = next_permutation;
//# sourceMappingURL=mathematics.js.map
+78
View File
@@ -0,0 +1,78 @@
import { IBidirectionalContainer } from "../container/IBidirectionalContainer";
import { IForwardContainer } from "../container/IForwardContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { Writeonly } from "../../internal/functional/Writeonly";
import { Comparator } from "../../internal/functional/Comparator";
/**
* Merge two sorted ranges.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function merge<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range1>, OutputIterator>>>(range1: Range1, range2: Range2, output: OutputIterator, comp?: Comparator<IForwardContainer.ValueType<Range1>>): OutputIterator;
/**
* Merge two sorted & consecutive ranges.
*
* @param range An iterable ranged container.
* @param middle Bidirectional iterator of the initial position of the 2nd range.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function inplace_merge<Range extends Array<any> | IBidirectionalContainer<any, any>>(range: Range, middle: IBidirectionalContainer.IteratorType<Range>, comp?: Comparator<IForwardContainer.ValueType<Range>>): void;
/**
* Test whether two sorted ranges are in inclusion relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether [first, last1) includes [first2, last2).
*/
export declare function includes<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2, comp?: Comparator<IForwardContainer.ValueType<Range1>>): boolean;
/**
* Combine two sorted ranges to union relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function set_union<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range1>, OutputIterator>>>(range1: Range1, range2: Range2, output: OutputIterator, comp?: Comparator<IForwardContainer.ValueType<Range1>>): OutputIterator;
/**
* Combine two sorted ranges to intersection relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function set_intersection<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range1>, OutputIterator>>>(range1: Range1, range2: Range2, output: OutputIterator, comp?: Comparator<IForwardContainer.ValueType<Range1>>): OutputIterator;
/**
* Combine two sorted ranges to difference relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function set_difference<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range1>, OutputIterator>>>(range1: Range1, range2: Range2, output: OutputIterator, comp?: Comparator<IForwardContainer.ValueType<Range1>>): OutputIterator;
/**
* Combine two sorted ranges to symmetric difference relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function set_symmetric_difference<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range1>, OutputIterator>>>(range1: Range1, range2: Range2, output: OutputIterator, comp?: Comparator<IForwardContainer.ValueType<Range1>>): OutputIterator;
+147
View File
@@ -0,0 +1,147 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.set_symmetric_difference = exports.set_difference = exports.set_intersection = exports.set_union = exports.includes = exports.inplace_merge = exports.merge = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/merge"));
var factory_1 = require("../../iterator/factory");
var global_1 = require("../../iterator/global");
var comparators_1 = require("../../functional/comparators");
/* ---------------------------------------------------------
MERGE
--------------------------------------------------------- */
/**
* Merge two sorted ranges.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
function merge(range1, range2, output, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.merge((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), output, comp);
}
exports.merge = merge;
/**
* Merge two sorted & consecutive ranges.
*
* @param range An iterable ranged container.
* @param middle Bidirectional iterator of the initial position of the 2nd range.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function inplace_merge(range, middle, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.inplace_merge((0, factory_1.begin)(range), middle, (0, factory_1.end)(range), comp);
}
exports.inplace_merge = inplace_merge;
/* ---------------------------------------------------------
SET OPERATIONS
--------------------------------------------------------- */
/**
* Test whether two sorted ranges are in inclusion relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether [first, last1) includes [first2, last2).
*/
function includes(range1, range2, comp) {
if (comp === void 0) { comp = comparators_1.less; }
if ((0, global_1.size)(range1) < (0, global_1.size)(range2))
return false;
else
return base.includes((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), comp);
}
exports.includes = includes;
/**
* Combine two sorted ranges to union relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
function set_union(range1, range2, output, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.set_union((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), output, comp);
}
exports.set_union = set_union;
/**
* Combine two sorted ranges to intersection relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
function set_intersection(range1, range2, output, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.set_intersection((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), output, comp);
}
exports.set_intersection = set_intersection;
/**
* Combine two sorted ranges to difference relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
function set_difference(range1, range2, output, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.set_difference((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), output, comp);
}
exports.set_difference = set_difference;
/**
* Combine two sorted ranges to symmetric difference relationship.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Output Iterator of the last position by advancing.
*/
function set_symmetric_difference(range1, range2, output, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.set_symmetric_difference((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), (0, factory_1.end)(range2), output, comp);
}
exports.set_symmetric_difference = set_symmetric_difference;
//# sourceMappingURL=merge.js.map
+262
View File
@@ -0,0 +1,262 @@
import { IBidirectionalContainer } from "../container/IBidirectionalContainer";
import { IForwardContainer } from "../container/IForwardContainer";
import { IRandomAccessContainer } from "../container/IRandomAccessContainer";
import { IBidirectionalIterator } from "../../iterator/IBidirectionalIterator";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { IPointer } from "../../functional/IPointer";
import { BinaryPredicator } from "../../internal/functional/BinaryPredicator";
import { UnaryPredicator } from "../../internal/functional/UnaryPredicator";
import { Writeonly } from "../../internal/functional/Writeonly";
declare type UnaryOperatorInferrer<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>> = (val: IForwardContainer.ValueType<Range>) => IPointer.ValueType<OutputIterator>;
declare type BinaryOperatorInferrer<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>> = (x: IForwardContainer.ValueType<Range1>, y: IForwardContainer.ValueType<Range2>) => IPointer.ValueType<OutputIterator>;
/**
* Copy elements in range.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function copy<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator): OutputIterator;
/**
* Copy *n* elements.
*
* @param range An iterable ranged container.
* @param n Number of elements to copy.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function copy_n<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, n: number, output: OutputIterator): OutputIterator;
/**
* Copy specific elements by a condition.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param pred A function predicates the specific condition.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function copy_if<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): OutputIterator;
/**
* Copy elements reversely.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function copy_backward<Range extends Array<any> | IBidirectionalContainer<any, any>, OutputIterator extends Writeonly<IBidirectionalIterator<IBidirectionalContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator): OutputIterator;
/**
* Fill range elements
*
* @param range An iterable ranged container.
* @param val The value to fill.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function fill<Range extends Array<any> | IForwardContainer<any>>(range: Range, value: IForwardContainer.ValueType<Range>): void;
/**
* Fill *n* elements.
*
* @param range An iterable ranged container.
* @param n Number of elements to fill.
* @param val The value to fill.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function fill_n<Range extends Array<any> | IForwardContainer<any>>(range: Range, n: number, value: IForwardContainer.ValueType<Range>): IForwardContainer.IteratorType<Range>;
/**
* Transform elements.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param op Unary function determines the transform.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function transform<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>>(range: Range, result: OutputIterator, op: UnaryOperatorInferrer<Range, OutputIterator>): OutputIterator;
/**
* Transform elements.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
* @param output Output iterator of the first position.
* @param op Binary function determines the transform.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function transform<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>>(range: Range1, first: Range2, result: OutputIterator, op: BinaryOperatorInferrer<Range1, Range2, OutputIterator>): OutputIterator;
/**
* Generate range elements.
*
* @param range An iterable ranged container.
* @param gen The generator function.
*/
export declare function generate<Range extends Array<any> | IForwardContainer<any>>(range: Range, gen: () => IForwardContainer.ValueType<Range>): void;
/**
* Generate *n* elements.
*
* @param range An iterable ranged container.
* @param n Number of elements to generate.
* @param gen The generator function.
*
* @return Forward Iterator to the last position by advancing.
*/
export declare function generate_n<Range extends Array<any> | IForwardContainer<any>>(range: Range, n: number, gen: () => IForwardContainer.ValueType<Range>): IForwardContainer.IteratorType<Range>;
/**
* Test whether elements are unique in sorted range.
*
* @param range An iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @returns Whether unique or not.
*/
export declare function is_unique<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred?: BinaryPredicator<IForwardContainer.ValueType<Range>>): boolean;
/**
* Remove duplicated elements in sorted range.
*
* @param range An iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Input iterator to the last element not removed.
*/
export declare function unique<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred?: BinaryPredicator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Copy elements in range without duplicates.
*
* @param range An iterable ranged container.
* @param output Output iterator of the last position.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function unique_copy<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, pred?: BinaryPredicator<IForwardContainer.ValueType<Range>>): OutputIterator;
/**
* Remove specific value in range.
*
* @param range An iterable ranged container.
* @param val The specific value to remove.
*
* @return Iterator tho the last element not removed.
*/
export declare function remove<Range extends Array<any> | IForwardContainer<any>>(range: Range, val: IForwardContainer.ValueType<Range>): IForwardContainer.IteratorType<Range>;
/**
* Remove elements in range by a condition.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates remove.
*
* @return Iterator tho the last element not removed.
*/
export declare function remove_if<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Copy range removing specific value.
*
* @param range An iterable ranged container.
* @param output Output iterator of the last position.
* @param val The condition predicates remove.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function remove_copy<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, val: IForwardContainer.ValueType<Range>): OutputIterator;
/**
* Copy range removing elements by a condition.
*
* @param range An iterable ranged container.
* @param output Output iterator of the last position.
* @param pred An unary function predicates remove.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function remove_copy_if<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): OutputIterator;
/**
* Replace specific value in range.
*
* @param range An iterable ranged container.
* @param old_val Specific value to change
* @param new_val Specific value to be changed.
*/
export declare function replace<Range extends Array<any> | IForwardContainer<any>>(range: Range, old_val: IForwardContainer.ValueType<Range>, new_val: IForwardContainer.ValueType<Range>): void;
/**
* Replace specific condition in range.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates the change.
* @param new_val Specific value to be changed.
*/
export declare function replace_if<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>, new_val: IForwardContainer.ValueType<Range>): void;
/**
* Copy range replacing specific value.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param old_val Specific value to change
* @param new_val Specific value to be changed.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function replace_copy<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, old_val: IForwardContainer.ValueType<Range>, new_val: IForwardContainer.ValueType<Range>): OutputIterator;
/**
* Copy range replacing specfic condition.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param pred An unary function predicates the change.
* @param new_val Specific value to be changed.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function replace_copy_if<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>, new_val: IForwardContainer.ValueType<Range>): OutputIterator;
/**
* Swap values of two ranges.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
*
* @return Forward Iterator of the last position of the 2nd range by advancing.
*/
export declare function swap_ranges<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends IForwardContainer.SimilarType<Range1>>(range1: Range1, range2: Range2): IForwardContainer.IteratorType<Range2>;
/**
* Reverse elements in range.
*
* @param range An iterable ranged container.
*/
export declare function reverse<Range extends Array<any> | IBidirectionalContainer<any, any>>(range: Range): void;
/**
* Copy reversed elements in range.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function reverse_copy<Range extends Array<any> | IBidirectionalContainer<any, any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator): OutputIterator;
export declare function shift_left<Range extends Array<any> | IForwardContainer<any>>(range: Range, n: number): void;
export declare function shift_right<Range extends Array<any> | IBidirectionalContainer<any, any>>(range: Range, n: number): void;
/**
* Rotate elements in range.
*
* @param range An iterable ranged container.
* @param middle Input iteartor of the initial position of the right side.
*
* @return Input iterator of the final position in the left side; *middle*.
*/
export declare function rotate<Range extends Array<any> | IForwardContainer<any>>(range: Range, middle: IForwardContainer.IteratorType<Range>): IForwardContainer.IteratorType<Range>;
/**
* Copy rotated elements in range.
*
* @param range An iterable ranged container.
* @param middle Input iteartor of the initial position of the right side.
* @param output Output iterator of the last position.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function rotate_copy<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, middle: IForwardContainer.IteratorType<Range>, output: OutputIterator): OutputIterator;
/**
* Shuffle elements in range.
*
* @param range An iterable ranged container.
*/
export declare function shuffle<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range): void;
export {};
+399
View File
@@ -0,0 +1,399 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.shuffle = exports.rotate_copy = exports.rotate = exports.shift_right = exports.shift_left = exports.reverse_copy = exports.reverse = exports.swap_ranges = exports.replace_copy_if = exports.replace_copy = exports.replace_if = exports.replace = exports.remove_copy_if = exports.remove_copy = exports.remove_if = exports.remove = exports.unique_copy = exports.unique = exports.is_unique = exports.generate_n = exports.generate = exports.transform = exports.fill_n = exports.fill = exports.copy_backward = exports.copy_if = exports.copy_n = exports.copy = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/modifiers"));
var factory_1 = require("../../iterator/factory");
var comparators_1 = require("../../functional/comparators");
/* ---------------------------------------------------------
FILL
--------------------------------------------------------- */
/**
* Copy elements in range.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
function copy(range, output) {
return base.copy((0, factory_1.begin)(range), (0, factory_1.end)(range), output);
}
exports.copy = copy;
/**
* Copy *n* elements.
*
* @param range An iterable ranged container.
* @param n Number of elements to copy.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
function copy_n(range, n, output) {
return base.copy_n((0, factory_1.begin)(range), n, output);
}
exports.copy_n = copy_n;
/**
* Copy specific elements by a condition.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param pred A function predicates the specific condition.
*
* @return Output Iterator of the last position by advancing.
*/
function copy_if(range, output, pred) {
return base.copy_if((0, factory_1.begin)(range), (0, factory_1.end)(range), output, pred);
}
exports.copy_if = copy_if;
/**
* Copy elements reversely.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
function copy_backward(range, output) {
return base.copy_backward((0, factory_1.begin)(range), (0, factory_1.end)(range), output);
}
exports.copy_backward = copy_backward;
/**
* Fill range elements
*
* @param range An iterable ranged container.
* @param val The value to fill.
*
* @return Output Iterator of the last position by advancing.
*/
function fill(range, value) {
return base.fill((0, factory_1.begin)(range), (0, factory_1.end)(range), value);
}
exports.fill = fill;
/**
* Fill *n* elements.
*
* @param range An iterable ranged container.
* @param n Number of elements to fill.
* @param val The value to fill.
*
* @return Output Iterator of the last position by advancing.
*/
function fill_n(range, n, value) {
return base.fill_n((0, factory_1.begin)(range), n, value);
}
exports.fill_n = fill_n;
function transform(range1) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var fn = base.transform.bind(undefined, (0, factory_1.begin)(range1), (0, factory_1.end)(range1));
if (args.length === 3)
return fn.apply(void 0, __spreadArray([], __read(args), false));
// args: #4
else
return fn((0, factory_1.end)(args[1]), args[2], args[3]);
}
exports.transform = transform;
/**
* Generate range elements.
*
* @param range An iterable ranged container.
* @param gen The generator function.
*/
function generate(range, gen) {
return base.generate((0, factory_1.begin)(range), (0, factory_1.end)(range), gen);
}
exports.generate = generate;
/**
* Generate *n* elements.
*
* @param range An iterable ranged container.
* @param n Number of elements to generate.
* @param gen The generator function.
*
* @return Forward Iterator to the last position by advancing.
*/
function generate_n(range, n, gen) {
return base.generate_n((0, factory_1.begin)(range), n, gen);
}
exports.generate_n = generate_n;
/* ---------------------------------------------------------
REMOVE
--------------------------------------------------------- */
/**
* Test whether elements are unique in sorted range.
*
* @param range An iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @returns Whether unique or not.
*/
function is_unique(range, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.is_unique((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.is_unique = is_unique;
/**
* Remove duplicated elements in sorted range.
*
* @param range An iterable ranged container.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Input iterator to the last element not removed.
*/
function unique(range, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.unique((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.unique = unique;
/**
* Copy elements in range without duplicates.
*
* @param range An iterable ranged container.
* @param output Output iterator of the last position.
* @param pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
*
* @return Output Iterator of the last position by advancing.
*/
function unique_copy(range, output, pred) {
if (pred === void 0) { pred = comparators_1.equal_to; }
return base.unique_copy((0, factory_1.begin)(range), (0, factory_1.end)(range), output, pred);
}
exports.unique_copy = unique_copy;
/**
* Remove specific value in range.
*
* @param range An iterable ranged container.
* @param val The specific value to remove.
*
* @return Iterator tho the last element not removed.
*/
function remove(range, val) {
return base.remove((0, factory_1.begin)(range), (0, factory_1.end)(range), val);
}
exports.remove = remove;
/**
* Remove elements in range by a condition.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates remove.
*
* @return Iterator tho the last element not removed.
*/
function remove_if(range, pred) {
return base.remove_if((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.remove_if = remove_if;
/**
* Copy range removing specific value.
*
* @param range An iterable ranged container.
* @param output Output iterator of the last position.
* @param val The condition predicates remove.
*
* @return Output Iterator of the last position by advancing.
*/
function remove_copy(range, output, val) {
return base.remove_copy((0, factory_1.begin)(range), (0, factory_1.end)(range), output, val);
}
exports.remove_copy = remove_copy;
/**
* Copy range removing elements by a condition.
*
* @param range An iterable ranged container.
* @param output Output iterator of the last position.
* @param pred An unary function predicates remove.
*
* @return Output Iterator of the last position by advancing.
*/
function remove_copy_if(range, output, pred) {
return base.remove_copy_if((0, factory_1.begin)(range), (0, factory_1.end)(range), output, pred);
}
exports.remove_copy_if = remove_copy_if;
/* ---------------------------------------------------------
REPLACE & SWAP
--------------------------------------------------------- */
/**
* Replace specific value in range.
*
* @param range An iterable ranged container.
* @param old_val Specific value to change
* @param new_val Specific value to be changed.
*/
function replace(range, old_val, new_val) {
return base.replace((0, factory_1.begin)(range), (0, factory_1.end)(range), old_val, new_val);
}
exports.replace = replace;
/**
* Replace specific condition in range.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates the change.
* @param new_val Specific value to be changed.
*/
function replace_if(range, pred, new_val) {
return base.replace_if((0, factory_1.begin)(range), (0, factory_1.end)(range), pred, new_val);
}
exports.replace_if = replace_if;
/**
* Copy range replacing specific value.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param old_val Specific value to change
* @param new_val Specific value to be changed.
*
* @return Output Iterator of the last position by advancing.
*/
function replace_copy(range, output, old_val, new_val) {
return base.replace_copy((0, factory_1.begin)(range), (0, factory_1.end)(range), output, old_val, new_val);
}
exports.replace_copy = replace_copy;
/**
* Copy range replacing specfic condition.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param pred An unary function predicates the change.
* @param new_val Specific value to be changed.
*
* @return Output Iterator of the last position by advancing.
*/
function replace_copy_if(range, output, pred, new_val) {
return base.replace_copy_if((0, factory_1.begin)(range), (0, factory_1.end)(range), output, pred, new_val);
}
exports.replace_copy_if = replace_copy_if;
/**
* Swap values of two ranges.
*
* @param range1 The 1st iterable ranged container.
* @param range2 The 2nd iterable ranged container.
*
* @return Forward Iterator of the last position of the 2nd range by advancing.
*/
function swap_ranges(range1, range2) {
return base.swap_ranges((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2));
}
exports.swap_ranges = swap_ranges;
/* ---------------------------------------------------------
RE-ARRANGEMENT
--------------------------------------------------------- */
/**
* Reverse elements in range.
*
* @param range An iterable ranged container.
*/
function reverse(range) {
return base.reverse((0, factory_1.begin)(range), (0, factory_1.end)(range));
}
exports.reverse = reverse;
/**
* Copy reversed elements in range.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
*
* @return Output Iterator of the last position by advancing.
*/
function reverse_copy(range, output) {
return base.reverse_copy((0, factory_1.begin)(range), (0, factory_1.end)(range), output);
}
exports.reverse_copy = reverse_copy;
function shift_left(range, n) {
return base.shift_left((0, factory_1.begin)(range), (0, factory_1.end)(range), n);
}
exports.shift_left = shift_left;
function shift_right(range, n) {
return base.shift_right((0, factory_1.begin)(range), (0, factory_1.end)(range), n);
}
exports.shift_right = shift_right;
/**
* Rotate elements in range.
*
* @param range An iterable ranged container.
* @param middle Input iteartor of the initial position of the right side.
*
* @return Input iterator of the final position in the left side; *middle*.
*/
function rotate(range, middle) {
return base.rotate((0, factory_1.begin)(range), middle, (0, factory_1.end)(range));
}
exports.rotate = rotate;
/**
* Copy rotated elements in range.
*
* @param range An iterable ranged container.
* @param middle Input iteartor of the initial position of the right side.
* @param output Output iterator of the last position.
*
* @return Output Iterator of the last position by advancing.
*/
function rotate_copy(range, middle, output) {
return base.rotate_copy((0, factory_1.begin)(range), middle, (0, factory_1.end)(range), output);
}
exports.rotate_copy = rotate_copy;
/**
* Shuffle elements in range.
*
* @param range An iterable ranged container.
*/
function shuffle(range) {
return base.shuffle((0, factory_1.begin)(range), (0, factory_1.end)(range));
}
exports.shuffle = shuffle;
//# sourceMappingURL=modifiers.js.map
+53
View File
@@ -0,0 +1,53 @@
import { IBidirectionalContainer } from "../container/IBidirectionalContainer";
import { IForwardContainer } from "../container/IForwardContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { Pair } from "../../utility/Pair";
import { UnaryPredicator } from "../../internal/functional/UnaryPredicator";
import { Writeonly } from "../../internal/functional/Writeonly";
/**
* Test whether a range is partitioned.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Whether the range is partition or not.
*/
export declare function is_partitioned<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): boolean;
/**
* Get partition point.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
export declare function partition_point<Range extends Array<any> | IForwardContainer<any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
/**
* Partition a range into two sections.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
export declare function partition<Range extends Array<any> | IBidirectionalContainer<any, any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): IBidirectionalContainer.IteratorType<Range>;
/**
* Partition a range into two sections with stable ordering.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
export declare function stable_partition<Range extends Array<any> | IBidirectionalContainer<any, any>>(range: Range, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): IBidirectionalContainer.IteratorType<Range>;
/**
* Partition a range into two outputs.
*
* @param range An iterable ranged container.
* @param output_true Output iterator to the first position for the first section.
* @param output_false Output iterator to the first position for the second section.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
export declare function partition_copy<Range extends Array<any> | IForwardContainer<any>, OutputIterator1 extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator1>>, OutputIterator2 extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator2>>>(range: Range, output_true: OutputIterator1, output_false: OutputIterator2, pred: UnaryPredicator<IForwardContainer.ValueType<Range>>): Pair<OutputIterator1, OutputIterator2>;
+97
View File
@@ -0,0 +1,97 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.partition_copy = exports.stable_partition = exports.partition = exports.partition_point = exports.is_partitioned = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/partition"));
var factory_1 = require("../../iterator/factory");
/**
* Test whether a range is partitioned.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Whether the range is partition or not.
*/
function is_partitioned(range, pred) {
return base.is_partitioned((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.is_partitioned = is_partitioned;
/**
* Get partition point.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
function partition_point(range, pred) {
return base.partition_point((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.partition_point = partition_point;
/**
* Partition a range into two sections.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
function partition(range, pred) {
return base.partition((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.partition = partition;
/**
* Partition a range into two sections with stable ordering.
*
* @param range An iterable ranged container.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
function stable_partition(range, pred) {
return base.stable_partition((0, factory_1.begin)(range), (0, factory_1.end)(range), pred);
}
exports.stable_partition = stable_partition;
/**
* Partition a range into two outputs.
*
* @param range An iterable ranged container.
* @param output_true Output iterator to the first position for the first section.
* @param output_false Output iterator to the first position for the second section.
* @param pred An unary function predicates partition. Returns `true`, if an element belongs to the first section, otherwise `false` which means the element belongs to the second section.
*
* @return Iterator to the first element of the second section.
*/
function partition_copy(range, output_true, output_false, pred) {
return base.partition_copy((0, factory_1.begin)(range), (0, factory_1.end)(range), output_true, output_false, pred);
}
exports.partition_copy = partition_copy;
//# sourceMappingURL=partition.js.map
+14
View File
@@ -0,0 +1,14 @@
import { IForwardContainer } from "../container/IForwardContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { IPointer } from "../../functional/IPointer";
import { Writeonly } from "../../internal/functional/Writeonly";
/**
* Pick sample elements up.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param n Number of elements to pick up.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function sample<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>>(range: Range, first: OutputIterator, n: number): OutputIterator;
+48
View File
@@ -0,0 +1,48 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sample = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/random"));
var factory_1 = require("../../iterator/factory");
/**
* Pick sample elements up.
*
* @param range An iterable ranged container.
* @param output Output iterator of the first position.
* @param n Number of elements to pick up.
*
* @return Output Iterator of the last position by advancing.
*/
function sample(range, first, n) {
return base.sample((0, factory_1.begin)(range), (0, factory_1.end)(range), first, n);
}
exports.sample = sample;
//# sourceMappingURL=random.js.map
+61
View File
@@ -0,0 +1,61 @@
import { IForwardContainer } from "../container/IForwardContainer";
import { IRandomAccessContainer } from "../container/IRandomAccessContainer";
import { Comparator } from "../../internal/functional/Comparator";
/**
* Sort elements in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function sort<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): void;
/**
* Sort elements in range stably.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function stable_sort<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): void;
/**
* Sort elements in range partially.
*
* @param range An iterable ranged container.
* @param middle Random access iterator of the middle position between [first, last). Elements only in [first, middle) are fully sorted.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function partial_sort<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, middle: IRandomAccessContainer.IteratorType<Range>, comp?: Comparator<IForwardContainer.ValueType<Range>>): void;
/**
* Copy elements in range with partial sort.
*
* @param range An iterable ranged container of input.
* @param output An iterable ranged container of output.
*
* @return Output Iterator of the last position by advancing.
*/
export declare function partial_sort_copy<Range extends Array<any> | IForwardContainer<any>, Output extends Array<any> | IForwardContainer<any>>(range: Range, output: Output, comp?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Output>;
/**
* Rearrange for the n'th element.
*
* @param range An iterable ranged container.
* @param nth Random access iterator the n'th position.
* @param last Random access iterator of the last position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
export declare function nth_element<Range extends Array<any> | IRandomAccessContainer<any>>(range: Range, nth: IRandomAccessContainer.IteratorType<Range>, comp?: Comparator<IForwardContainer.ValueType<Range>>): void;
/**
* Test whether a range is sorted.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether sorted or not.
*/
export declare function is_sorted<Range extends Array<any> | IForwardContainer<any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): boolean;
/**
* Find the first unsorted element in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element who violates the order.
*/
export declare function is_sorted_until<Range extends Array<any> | IForwardContainer<any>>(range: Range, comp?: Comparator<IForwardContainer.ValueType<Range>>): IForwardContainer.IteratorType<Range>;
+128
View File
@@ -0,0 +1,128 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.is_sorted_until = exports.is_sorted = exports.nth_element = exports.partial_sort_copy = exports.partial_sort = exports.stable_sort = exports.sort = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../algorithm/sorting"));
var factory_1 = require("../../iterator/factory");
var comparators_1 = require("../../functional/comparators");
/* ---------------------------------------------------------
SORT
--------------------------------------------------------- */
/**
* Sort elements in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function sort(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.sort((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.sort = sort;
/**
* Sort elements in range stably.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function stable_sort(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.stable_sort((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.stable_sort = stable_sort;
/**
* Sort elements in range partially.
*
* @param range An iterable ranged container.
* @param middle Random access iterator of the middle position between [first, last). Elements only in [first, middle) are fully sorted.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function partial_sort(range, middle, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.partial_sort((0, factory_1.begin)(range), middle, (0, factory_1.end)(range), comp);
}
exports.partial_sort = partial_sort;
/**
* Copy elements in range with partial sort.
*
* @param range An iterable ranged container of input.
* @param output An iterable ranged container of output.
*
* @return Output Iterator of the last position by advancing.
*/
function partial_sort_copy(range, output, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.partial_sort_copy((0, factory_1.begin)(range), (0, factory_1.end)(range), (0, factory_1.begin)(output), (0, factory_1.end)(output), comp);
}
exports.partial_sort_copy = partial_sort_copy;
/**
* Rearrange for the n'th element.
*
* @param range An iterable ranged container.
* @param nth Random access iterator the n'th position.
* @param last Random access iterator of the last position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*/
function nth_element(range, nth, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.nth_element((0, factory_1.begin)(range), nth, (0, factory_1.end)(range), comp);
}
exports.nth_element = nth_element;
/* ---------------------------------------------------------
INSPECTOR
--------------------------------------------------------- */
/**
* Test whether a range is sorted.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Whether sorted or not.
*/
function is_sorted(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.is_sorted((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.is_sorted = is_sorted;
/**
* Find the first unsorted element in range.
*
* @param range An iterable ranged container.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
*
* @return Iterator to the first element who violates the order.
*/
function is_sorted_until(range, comp) {
if (comp === void 0) { comp = comparators_1.less; }
return base.is_sorted_until((0, factory_1.begin)(range), (0, factory_1.end)(range), comp);
}
exports.is_sorted_until = is_sorted_until;
//# sourceMappingURL=sorting.js.map
+43
View File
@@ -0,0 +1,43 @@
/**
* @packageDocumentation
* @module std.ranges
*/
import { IForwardContainer } from "./IForwardContainer";
import { IReverseIterator } from "../../iterator/IReverseIterator";
import { IReversableIterator } from "../../iterator/IReversableIterator";
import { IPointer } from "../../functional/IPointer";
import { Vector } from "../../container/Vector";
/**
* Bidirection iterable container.
*
* @template Iterator Iterator type
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IBidirectionalContainer<IteratorT extends IReversableIterator<IPointer.ValueType<IteratorT>, IteratorT, ReverseIteratorT>, ReverseIteratorT extends IReverseIterator<IPointer.ValueType<IteratorT>, IteratorT, ReverseIteratorT>> extends IForwardContainer<IteratorT> {
/**
* Reverse iterator to the first element in reverse.
*
* @return Reverse iterator to the first.
*/
rbegin(): ReverseIteratorT;
/**
* Reverse iterator to the reverse end.
*
* @return Reverse iterator to the end.
*/
rend(): ReverseIteratorT;
}
export declare namespace IBidirectionalContainer {
/**
* Deduct iterator type.
*/
type IteratorType<Container extends Array<any> | IBidirectionalContainer<any, any>> = Container extends Array<infer T> ? Vector.Iterator<T> : Container extends IBidirectionalContainer<infer Iterator, any> ? Iterator : unknown;
/**
* Deduct reverse iterator type.
*/
type ReverseIteratorType<Container extends Array<any> | IBidirectionalContainer<any, any>> = Container extends Array<infer T> ? Vector.ReverseIterator<T> : Container extends IBidirectionalContainer<any, infer ReverseIterator> ? ReverseIterator : unknown;
/**
* Deduct value type.
*/
type ValueType<Container extends Array<any> | IBidirectionalContainer<any, any>> = IPointer.ValueType<IteratorType<Container>>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IBidirectionalContainer.js.map
+42
View File
@@ -0,0 +1,42 @@
/**
* @packageDocumentation
* @module std.ranges
*/
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { IPointer } from "../../functional/IPointer";
import { ISize } from "../../internal/container/partial/ISize";
import { Vector } from "../../container/Vector";
/**
* Forward iterable container.
*
* @template Iterator Iterator type
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IForwardContainer<Iterator extends IForwardIterator<IPointer.ValueType<Iterator>, Iterator>> extends ISize {
/**
* Iterator to the first element.
*
* @return Iterator to the first element.
*/
begin(): Iterator;
/**
* Iterator to the end.
*
* @return Iterator to the end.
*/
end(): Iterator;
}
export declare namespace IForwardContainer {
/**
* Deduct iterator type.
*/
type IteratorType<Container extends Array<any> | IForwardContainer<any>> = Container extends Array<infer T> ? Vector.Iterator<T> : Container extends IForwardContainer<infer Iterator> ? Iterator : unknown;
/**
* Deduct value type.
*/
type ValueType<Container extends Array<any> | IForwardContainer<any>> = IPointer.ValueType<IteratorType<Container>>;
/**
* Deduct similar type.
*/
type SimilarType<Container extends Array<any> | IForwardContainer<any>> = Array<ValueType<Container>> | IForwardContainer<IForwardIterator<ValueType<Container>, any>>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IForwardContainer.js.map
+26
View File
@@ -0,0 +1,26 @@
/**
* @packageDocumentation
* @module std.ranges
*/
import { IForwardContainer } from "./IForwardContainer";
import { IRandomAccessIterator } from "../../iterator/IRandomAccessIterator";
import { IPointer } from "../../functional/IPointer";
import { Vector } from "../../container/Vector";
/**
* Random-access iterable container.
*
* @template Iterator Iterator type
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IRandomAccessContainer<IteratorT extends IRandomAccessIterator<IPointer.ValueType<IteratorT>, IteratorT>> extends IForwardContainer<IteratorT> {
}
export declare namespace IRandomAccessContainer {
/**
* Deduct iterator type.
*/
type IteratorType<Container extends Array<any> | IRandomAccessContainer<any>> = Container extends Array<infer T> ? Vector.Iterator<T> : Container extends IRandomAccessContainer<infer Iterator> ? Iterator : unknown;
/**
* Deduct value type.
*/
type ValueType<Container extends Array<any> | IRandomAccessContainer<any>> = IForwardContainer.ValueType<IteratorType<Container>>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IRandomAccessContainer.js.map
+7
View File
@@ -0,0 +1,7 @@
/**
* @packageDocumentation
* @module std.ranges
*/
export * from "./IForwardContainer";
export * from "./IBidirectionalContainer";
export * from "./IRandomAccessContainer";
+26
View File
@@ -0,0 +1,26 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
__exportStar(require("./IForwardContainer"), exports);
__exportStar(require("./IBidirectionalContainer"), exports);
__exportStar(require("./IRandomAccessContainer"), exports);
//# sourceMappingURL=index.js.map
+10
View File
@@ -0,0 +1,10 @@
/**
* Ranged Features
*
* @packageDocumentation
* @module std.ranges
* @preferred
*/
import * as ranges from "./module";
export default ranges;
export * from "./module";
+41
View File
@@ -0,0 +1,41 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
//================================================================
/**
* Ranged Features
*
* @packageDocumentation
* @module std.ranges
* @preferred
*/
//================================================================
var ranges = __importStar(require("./module"));
exports.default = ranges;
__exportStar(require("./module"), exports);
//# sourceMappingURL=index.js.map
+7
View File
@@ -0,0 +1,7 @@
/**
* @packageDocumentation
* @module std.ranges
*/
export * from "./algorithm/index";
export * from "./numeric/index";
export * from "./container/index";
+26
View File
@@ -0,0 +1,26 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
__exportStar(require("./algorithm/index"), exports);
__exportStar(require("./numeric/index"), exports);
__exportStar(require("./container/index"), exports);
//# sourceMappingURL=module.js.map
+5
View File
@@ -0,0 +1,5 @@
/**
* @packageDocumentation
* @module std.ranges
*/
export * from "./operations";
+24
View File
@@ -0,0 +1,24 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
__exportStar(require("./operations"), exports);
//# sourceMappingURL=index.js.map
+17
View File
@@ -0,0 +1,17 @@
import { IForwardContainer } from "../container/IForwardContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { IPointer } from "../../functional/IPointer";
import { Writeonly } from "../../internal/functional/Writeonly";
declare type UnaryTransformer<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>> = (val: IForwardContainer.ValueType<Range>) => IPointer.ValueType<OutputIterator>;
declare type BinaryTransformer<OutputIterator extends IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>> = (x: IPointer.ValueType<OutputIterator>, y: IPointer.ValueType<OutputIterator>) => IPointer.ValueType<OutputIterator>;
declare type Operator<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any> = Range1> = (x: IForwardContainer.ValueType<Range1>, y: IForwardContainer.ValueType<Range2>) => IForwardContainer.ValueType<Range1>;
export declare function iota<Range extends Array<any> | IForwardContainer<IForwardIterator<number, any>>>(range: Range, value: number): void;
export declare function accumulate<Range extends Array<any> | IForwardContainer<any>>(range: Range, init: IForwardContainer.ValueType<Range>, op?: Operator<Range>): IForwardContainer.ValueType<Range>;
export declare function inner_product<Range1 extends Array<any> | IForwardContainer<any>, Range2 extends Array<any> | IForwardContainer<any>>(range1: Range1, range2: Range2, value: IForwardContainer.ValueType<Range1>, adder?: Operator<Range1>, multiplier?: Operator<Range1, Range2>): IForwardContainer.ValueType<Range1>;
export declare function adjacent_difference<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, subtracter?: Operator<Range>): OutputIterator;
export declare function partial_sum<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, adder?: Operator<Range>): OutputIterator;
export declare function inclusive_scan<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, adder?: Operator<Range>, init?: IForwardContainer.ValueType<Range>): OutputIterator;
export declare function exclusive_scan<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends Writeonly<IForwardIterator<IForwardContainer.ValueType<Range>, OutputIterator>>>(range: Range, output: OutputIterator, init: IForwardContainer.ValueType<Range>, adder?: Operator<Range>): OutputIterator;
export declare function transform_inclusive_scan<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>(range: Range, output: OutputIterator, binary: BinaryTransformer<OutputIterator>, unary: UnaryTransformer<Range, OutputIterator>, init?: IForwardContainer.ValueType<Range>): OutputIterator;
export declare function transform_exclusive_scan<Range extends Array<any> | IForwardContainer<any>, OutputIterator extends IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>(range: Range, output: OutputIterator, init: IForwardContainer.ValueType<Range>, binary: BinaryTransformer<OutputIterator>, unary: UnaryTransformer<Range, OutputIterator>): OutputIterator;
export {};
+85
View File
@@ -0,0 +1,85 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.transform_exclusive_scan = exports.transform_inclusive_scan = exports.exclusive_scan = exports.inclusive_scan = exports.partial_sum = exports.adjacent_difference = exports.inner_product = exports.accumulate = exports.iota = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.ranges
*/
//================================================================
var base = __importStar(require("../../numeric/operations"));
var factory_1 = require("../../iterator/factory");
var operators_1 = require("../../numeric/operators");
/* ---------------------------------------------------------
COMMON ALGORITHMS
--------------------------------------------------------- */
function iota(range, value) {
return base.iota((0, factory_1.begin)(range), (0, factory_1.end)(range), value);
}
exports.iota = iota;
function accumulate(range, init, op) {
if (op === void 0) { op = operators_1.plus; }
return base.accumulate((0, factory_1.begin)(range), (0, factory_1.end)(range), init, op);
}
exports.accumulate = accumulate;
function inner_product(range1, range2, value, adder, multiplier) {
if (adder === void 0) { adder = operators_1.plus; }
if (multiplier === void 0) { multiplier = operators_1.multiplies; }
return base.inner_product((0, factory_1.begin)(range1), (0, factory_1.end)(range1), (0, factory_1.begin)(range2), value, adder, multiplier);
}
exports.inner_product = inner_product;
function adjacent_difference(range, output, subtracter) {
if (subtracter === void 0) { subtracter = operators_1.minus; }
return base.adjacent_difference((0, factory_1.begin)(range), (0, factory_1.end)(range), output, subtracter);
}
exports.adjacent_difference = adjacent_difference;
function partial_sum(range, output, adder) {
if (adder === void 0) { adder = operators_1.plus; }
return base.partial_sum((0, factory_1.begin)(range), (0, factory_1.end)(range), output, adder);
}
exports.partial_sum = partial_sum;
/* ---------------------------------------------------------
PREFIX SUMS
--------------------------------------------------------- */
function inclusive_scan(range, output, adder, init) {
if (adder === void 0) { adder = operators_1.plus; }
return base.inclusive_scan((0, factory_1.begin)(range), (0, factory_1.end)(range), output, adder, init);
}
exports.inclusive_scan = inclusive_scan;
function exclusive_scan(range, output, init, adder) {
if (adder === void 0) { adder = operators_1.plus; }
return base.exclusive_scan((0, factory_1.begin)(range), (0, factory_1.end)(range), output, init, adder);
}
exports.exclusive_scan = exclusive_scan;
function transform_inclusive_scan(range, output, binary, unary, init) {
return base.transform_inclusive_scan((0, factory_1.begin)(range), (0, factory_1.end)(range), output, binary, unary, init);
}
exports.transform_inclusive_scan = transform_inclusive_scan;
function transform_exclusive_scan(range, output, init, binary, unary) {
return base.transform_exclusive_scan((0, factory_1.begin)(range), (0, factory_1.end)(range), output, init, binary, unary);
}
exports.transform_exclusive_scan = transform_exclusive_scan;
//# sourceMappingURL=operations.js.map