include node_modules so release .zip is deployable
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { InsertIteratorBase } from "../internal/iterator/InsertIteratorBase";
|
||||
import { IPushBack } from "../internal/container/partial/IPushBack";
|
||||
import { Vector } from "../container/Vector";
|
||||
/**
|
||||
* Back insert iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class BackInsertIterator<Source extends IPushBack<BackInsertIterator.ValueType<Source>>> extends InsertIteratorBase<BackInsertIterator.ValueType<Source>, BackInsertIterator<Source>> {
|
||||
private source_;
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param source The source container.
|
||||
*/
|
||||
constructor(source: Source);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set value(val: BackInsertIterator.ValueType<Source>);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equals(obj: BackInsertIterator<Source>): boolean;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export declare namespace BackInsertIterator {
|
||||
/**
|
||||
* Deduct value type.
|
||||
*/
|
||||
type ValueType<Source extends IPushBack<any>> = Source extends IPushBack<infer T> ? T : unknown;
|
||||
/**
|
||||
* Deduct source type.
|
||||
*/
|
||||
type SourceType<Source extends Array<any> | IPushBack<any>> = Source extends Array<infer T> ? Vector<T> : Source;
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BackInsertIterator = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var InsertIteratorBase_1 = require("../internal/iterator/InsertIteratorBase");
|
||||
var comparators_1 = require("../functional/comparators");
|
||||
/**
|
||||
* Back insert iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var BackInsertIterator = /** @class */ (function (_super) {
|
||||
__extends(BackInsertIterator, _super);
|
||||
/* ---------------------------------------------------------
|
||||
METHODS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param source The source container.
|
||||
*/
|
||||
function BackInsertIterator(source) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.source_ = source;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(BackInsertIterator.prototype, "value", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.source_.push_back(val);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
BackInsertIterator.prototype.equals = function (obj) {
|
||||
return (0, comparators_1.equal_to)(this.source_, obj.source_);
|
||||
};
|
||||
return BackInsertIterator;
|
||||
}(InsertIteratorBase_1.InsertIteratorBase));
|
||||
exports.BackInsertIterator = BackInsertIterator;
|
||||
//# sourceMappingURL=BackInsertIterator.js.map
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { InsertIteratorBase } from "../internal/iterator/InsertIteratorBase";
|
||||
import { IPushFront } from "../internal/container/partial/IPushFront";
|
||||
/**
|
||||
* Front insert iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class FrontInsertIterator<Source extends IPushFront<FrontInsertIterator.ValueType<Source>>> extends InsertIteratorBase<FrontInsertIterator.ValueType<Source>, FrontInsertIterator<Source>> {
|
||||
private source_;
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param source The source container.
|
||||
*/
|
||||
constructor(source: Source);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set value(val: FrontInsertIterator.ValueType<Source>);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equals(obj: FrontInsertIterator<Source>): boolean;
|
||||
}
|
||||
export declare namespace FrontInsertIterator {
|
||||
/**
|
||||
* Deduct value type.
|
||||
*/
|
||||
type ValueType<Source extends IPushFront<any>> = Source extends IPushFront<infer T> ? T : unknown;
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FrontInsertIterator = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var InsertIteratorBase_1 = require("../internal/iterator/InsertIteratorBase");
|
||||
var comparators_1 = require("../functional/comparators");
|
||||
/**
|
||||
* Front insert iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var FrontInsertIterator = /** @class */ (function (_super) {
|
||||
__extends(FrontInsertIterator, _super);
|
||||
/* ---------------------------------------------------------
|
||||
METHODS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param source The source container.
|
||||
*/
|
||||
function FrontInsertIterator(source) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.source_ = source;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(FrontInsertIterator.prototype, "value", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.source_.push_front(val);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
FrontInsertIterator.prototype.equals = function (obj) {
|
||||
return (0, comparators_1.equal_to)(this.source_, obj.source_);
|
||||
};
|
||||
return FrontInsertIterator;
|
||||
}(InsertIteratorBase_1.InsertIteratorBase));
|
||||
exports.FrontInsertIterator = FrontInsertIterator;
|
||||
//# sourceMappingURL=FrontInsertIterator.js.map
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IForwardIterator } from "./IForwardIterator";
|
||||
/**
|
||||
* Bidirectional iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface IBidirectionalIterator<T, Iterator extends IBidirectionalIterator<T, Iterator> = IBidirectionalIterator<T, any>> extends IForwardIterator<T, Iterator> {
|
||||
/**
|
||||
* Get previous iterator.
|
||||
*
|
||||
* @return The previous iterator.
|
||||
*/
|
||||
prev(): Iterator;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IBidirectionalIterator.js.map
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IPointer } from "../functional/IPointer";
|
||||
import { IComparable } from "../functional/IComparable";
|
||||
/**
|
||||
* Forward iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface IForwardIterator<T, Iterator extends IForwardIterator<T, Iterator> = IForwardIterator<T, any>> extends IPointer<T>, Pick<IComparable<Iterator>, "equals"> {
|
||||
/**
|
||||
* Get next iterator.
|
||||
*
|
||||
* @return The next iterator.
|
||||
*/
|
||||
next(): Iterator;
|
||||
/**
|
||||
* Test whether equal to other iterator.
|
||||
*
|
||||
* @param obj The iterator to compare.
|
||||
* @return Whether equal or not.
|
||||
*/
|
||||
equals(obj: Iterator): boolean;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IForwardIterator.js.map
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IBidirectionalIterator } from "./IBidirectionalIterator";
|
||||
/**
|
||||
* Random access iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface IRandomAccessIterator<T, Iterator extends IRandomAccessIterator<T, Iterator> = IRandomAccessIterator<T, any>> extends IBidirectionalIterator<T, Iterator> {
|
||||
/**
|
||||
* Get index.
|
||||
*
|
||||
* @return The index.
|
||||
*/
|
||||
index(): number;
|
||||
/**
|
||||
* Advance iterator.
|
||||
*
|
||||
* @param n Step to advance.
|
||||
* @return The advanced iterator.
|
||||
*/
|
||||
advance(n: number): Iterator;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IRandomAccessIterator.js.map
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IBidirectionalIterator } from "./IBidirectionalIterator";
|
||||
import { IReverseIterator } from "./IReverseIterator";
|
||||
/**
|
||||
* Reversable iterator
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface IReversableIterator<T, IteratorT extends IReversableIterator<T, IteratorT, ReverseT>, ReverseT extends IReverseIterator<T, IteratorT, ReverseT>> extends IBidirectionalIterator<T, IteratorT> {
|
||||
/**
|
||||
* Construct reverse iterator.
|
||||
*
|
||||
* @return The reverse iterator.
|
||||
*/
|
||||
reverse(): ReverseT;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IReversableIterator.js.map
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IBidirectionalIterator } from "./IBidirectionalIterator";
|
||||
import { IReversableIterator } from "./IReversableIterator";
|
||||
/**
|
||||
* Reverse iterator
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface IReverseIterator<T, Base extends IReversableIterator<T, Base, This>, This extends IReverseIterator<T, Base, This>> extends IBidirectionalIterator<T, This> {
|
||||
/**
|
||||
* Get base iterator.
|
||||
*
|
||||
* @return The base iterator.
|
||||
*/
|
||||
base(): Base;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IReverseIterator.js.map
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { InsertIteratorBase } from "../internal/iterator/InsertIteratorBase";
|
||||
import { IForwardIterator } from "./IForwardIterator";
|
||||
import { IPointer } from "../functional/IPointer";
|
||||
import { IInsert } from "../internal/container/partial/IInsert";
|
||||
/**
|
||||
* Insert iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class InsertIterator<Container extends IInsert<Iterator>, Iterator extends IForwardIterator<IPointer.ValueType<Iterator>, Iterator>> extends InsertIteratorBase<IPointer.ValueType<Iterator>, InsertIterator<Container, Iterator>> {
|
||||
private container_;
|
||||
private it_;
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param container Target container to insert.
|
||||
* @param it Iterator to the position to insert.
|
||||
*/
|
||||
constructor(container: Container, it: Iterator);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set value(val: IPointer.ValueType<Iterator>);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equals(obj: InsertIterator<Container, Iterator>): boolean;
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InsertIterator = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var InsertIteratorBase_1 = require("../internal/iterator/InsertIteratorBase");
|
||||
var comparators_1 = require("../functional/comparators");
|
||||
/**
|
||||
* Insert iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var InsertIterator = /** @class */ (function (_super) {
|
||||
__extends(InsertIterator, _super);
|
||||
/* ---------------------------------------------------------
|
||||
METHODS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param container Target container to insert.
|
||||
* @param it Iterator to the position to insert.
|
||||
*/
|
||||
function InsertIterator(container, it) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.container_ = container;
|
||||
_this.it_ = it;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(InsertIterator.prototype, "value", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.it_ = this.container_.insert(this.it_, val);
|
||||
this.it_ = this.it_.next();
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
InsertIterator.prototype.equals = function (obj) {
|
||||
return (0, comparators_1.equal_to)(this.it_, obj.it_);
|
||||
};
|
||||
return InsertIterator;
|
||||
}(InsertIteratorBase_1.InsertIteratorBase));
|
||||
exports.InsertIterator = InsertIterator;
|
||||
//# sourceMappingURL=InsertIterator.js.map
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IBidirectionalContainer } from "../ranges/container/IBidirectionalContainer";
|
||||
import { IReversableIterator } from "./IReversableIterator";
|
||||
import { IReverseIterator } from "./IReverseIterator";
|
||||
import { IPointer } from "../functional/IPointer";
|
||||
import { IForwardContainer } from "../ranges/container/IForwardContainer";
|
||||
import { IInsert } from "../internal/container/partial/IInsert";
|
||||
import { IPushFront } from "../internal/container/partial/IPushFront";
|
||||
import { IPushBack } from "../internal/container/partial/IPushBack";
|
||||
import { InsertIterator } from "./InsertIterator";
|
||||
import { FrontInsertIterator } from "./FrontInsertIterator";
|
||||
import { BackInsertIterator } from "./BackInsertIterator";
|
||||
import { IForwardIterator } from "./IForwardIterator";
|
||||
/**
|
||||
* Iterator to the first element.
|
||||
*
|
||||
* @param container Target container.
|
||||
* @return Iterator to the first element.
|
||||
*/
|
||||
export declare function begin<Container extends Array<any> | IForwardContainer<any>>(container: Container): IForwardContainer.IteratorType<Container>;
|
||||
/**
|
||||
* Iterator to the end.
|
||||
*
|
||||
* @param container Target container.
|
||||
* @return Iterator to the end.
|
||||
*/
|
||||
export declare function end<Container extends Array<any> | IForwardContainer<any>>(container: Container): IForwardContainer.IteratorType<Container>;
|
||||
/**
|
||||
* Get reverse iterator to the first element in reverse.
|
||||
*
|
||||
* @param container Target container.
|
||||
* @return The reverse iterator to the first.
|
||||
*/
|
||||
export declare function rbegin<Container extends Array<any> | IBidirectionalContainer<any, any>>(container: Container): IBidirectionalContainer.ReverseIteratorType<Container>;
|
||||
/**
|
||||
* Get reverse iterator to the reverse end.
|
||||
*
|
||||
* @param container Target container.
|
||||
* @return The reverse iterator to the end.
|
||||
*/
|
||||
export declare function rend<Container extends Array<any> | IBidirectionalContainer<any, any>>(container: Container): IBidirectionalContainer.ReverseIteratorType<Container>;
|
||||
/**
|
||||
* Construct reverse iterator.
|
||||
*
|
||||
* @param it Target iterator that reversable.
|
||||
* @return The reverse iterator object.
|
||||
*/
|
||||
export declare function make_reverse_iterator<IteratorT extends IReversableIterator<IPointer.ValueType<IteratorT>, IteratorT, ReverseT>, ReverseT extends IReverseIterator<IPointer.ValueType<IteratorT>, IteratorT, ReverseT>>(it: IteratorT): ReverseT;
|
||||
/**
|
||||
* Construct insert iterator.
|
||||
*
|
||||
* @param container Target container.
|
||||
* @param it Iterator to the first insertion position.
|
||||
* @return The {@link InsertIterator insert iterator} object.
|
||||
*/
|
||||
export declare function inserter<Container extends IInsert<Iterator>, Iterator extends IForwardIterator<IPointer.ValueType<Iterator>, Iterator>>(container: Container, it: Iterator): InsertIterator<Container, Iterator>;
|
||||
/**
|
||||
* Construct front insert iterator.
|
||||
*
|
||||
* @param source Target container.
|
||||
* @return The {@link FrontInsertIterator front insert iterator} object.
|
||||
*/
|
||||
export declare function front_inserter<Source extends IPushFront<FrontInsertIterator.ValueType<Source>>>(source: Source): FrontInsertIterator<Source>;
|
||||
/**
|
||||
* Construct back insert iterator.
|
||||
*
|
||||
* @param source Target container.
|
||||
* @return The {@link back insert iterator} object.
|
||||
*/
|
||||
export declare function back_inserter<Source extends Array<any> | IPushBack<any>>(source: Source): BackInsertIterator<BackInsertIterator.SourceType<Source>>;
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.back_inserter = exports.front_inserter = exports.inserter = exports.make_reverse_iterator = exports.rend = exports.rbegin = exports.end = exports.begin = void 0;
|
||||
var InsertIterator_1 = require("./InsertIterator");
|
||||
var FrontInsertIterator_1 = require("./FrontInsertIterator");
|
||||
var BackInsertIterator_1 = require("./BackInsertIterator");
|
||||
var Vector_1 = require("../container/Vector");
|
||||
function begin(container) {
|
||||
if (container instanceof Array)
|
||||
container = Vector_1.Vector.wrap(container);
|
||||
return container.begin();
|
||||
}
|
||||
exports.begin = begin;
|
||||
function end(container) {
|
||||
if (container instanceof Array)
|
||||
container = Vector_1.Vector.wrap(container);
|
||||
return container.end();
|
||||
}
|
||||
exports.end = end;
|
||||
function rbegin(container) {
|
||||
if (container instanceof Array)
|
||||
container = Vector_1.Vector.wrap(container);
|
||||
return container.rbegin();
|
||||
}
|
||||
exports.rbegin = rbegin;
|
||||
function rend(container) {
|
||||
if (container instanceof Array)
|
||||
container = Vector_1.Vector.wrap(container);
|
||||
return container.rend();
|
||||
}
|
||||
exports.rend = rend;
|
||||
/**
|
||||
* Construct reverse iterator.
|
||||
*
|
||||
* @param it Target iterator that reversable.
|
||||
* @return The reverse iterator object.
|
||||
*/
|
||||
function make_reverse_iterator(it) {
|
||||
return it.reverse();
|
||||
}
|
||||
exports.make_reverse_iterator = make_reverse_iterator;
|
||||
/* ---------------------------------------------------------
|
||||
INSERTERS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Construct insert iterator.
|
||||
*
|
||||
* @param container Target container.
|
||||
* @param it Iterator to the first insertion position.
|
||||
* @return The {@link InsertIterator insert iterator} object.
|
||||
*/
|
||||
function inserter(container, it) {
|
||||
return new InsertIterator_1.InsertIterator(container, it);
|
||||
}
|
||||
exports.inserter = inserter;
|
||||
/**
|
||||
* Construct front insert iterator.
|
||||
*
|
||||
* @param source Target container.
|
||||
* @return The {@link FrontInsertIterator front insert iterator} object.
|
||||
*/
|
||||
function front_inserter(source) {
|
||||
return new FrontInsertIterator_1.FrontInsertIterator(source);
|
||||
}
|
||||
exports.front_inserter = front_inserter;
|
||||
function back_inserter(source) {
|
||||
if (source instanceof Array)
|
||||
source = Vector_1.Vector.wrap(source);
|
||||
return new BackInsertIterator_1.BackInsertIterator(source);
|
||||
}
|
||||
exports.back_inserter = back_inserter;
|
||||
//# sourceMappingURL=factory.js.map
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IPointer } from "../functional/IPointer";
|
||||
import { IForwardIterator } from "./IForwardIterator";
|
||||
import { IBidirectionalIterator } from "./IBidirectionalIterator";
|
||||
import { IEmpty } from "../internal/container/partial/IEmpty";
|
||||
import { ISize } from "../internal/container/partial/ISize";
|
||||
/**
|
||||
* Test whether a container is empty.
|
||||
*
|
||||
* @param source Target container.
|
||||
* @return Whether empty or not.
|
||||
*/
|
||||
export declare function empty(source: Array<any> | IEmpty): boolean;
|
||||
/**
|
||||
* Get number of elements of a container.
|
||||
*
|
||||
* @param source Target container.
|
||||
* @return The number of elements in the container.
|
||||
*/
|
||||
export declare function size(source: Array<any> | ISize): number;
|
||||
/**
|
||||
* Get distance between two iterators.
|
||||
*
|
||||
* @param first Input iteartor of the first position.
|
||||
* @param last Input iterator of the last position.
|
||||
*
|
||||
* @return The distance.
|
||||
*/
|
||||
export declare function distance<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>>(first: InputIterator, last: InputIterator): number;
|
||||
/**
|
||||
* Advance iterator.
|
||||
*
|
||||
* @param it Target iterator to advance.
|
||||
* @param n Step to advance.
|
||||
*
|
||||
* @return The advanced iterator.
|
||||
*/
|
||||
export declare function advance<InputIterator extends IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>(it: InputIterator, n: number): InputIterator;
|
||||
/**
|
||||
* Get previous iterator.
|
||||
*
|
||||
* @param it Iterator to move.
|
||||
* @param n Step to move prev.
|
||||
* @return An iterator moved to prev *n* steps.
|
||||
*/
|
||||
export declare function prev<BidirectionalIterator extends IBidirectionalIterator<IPointer.ValueType<BidirectionalIterator>, BidirectionalIterator>>(it: BidirectionalIterator, n?: number): BidirectionalIterator;
|
||||
/**
|
||||
* Get next iterator.
|
||||
*
|
||||
* @param it Iterator to move.
|
||||
* @param n Step to move next.
|
||||
* @return Iterator moved to next *n* steps.
|
||||
*/
|
||||
export declare function next<ForwardIterator extends IForwardIterator<IPointer.ValueType<ForwardIterator>, ForwardIterator>>(it: ForwardIterator, n?: number): ForwardIterator;
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.next = exports.prev = exports.advance = exports.distance = exports.size = exports.empty = void 0;
|
||||
var InvalidArgument_1 = require("../exception/InvalidArgument");
|
||||
/* =========================================================
|
||||
GLOBAL FUNCTIONS
|
||||
- ACCESSORS
|
||||
- MOVERS
|
||||
- FACTORIES
|
||||
============================================================
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Test whether a container is empty.
|
||||
*
|
||||
* @param source Target container.
|
||||
* @return Whether empty or not.
|
||||
*/
|
||||
function empty(source) {
|
||||
if (source instanceof Array)
|
||||
return source.length !== 0;
|
||||
else
|
||||
return source.empty();
|
||||
}
|
||||
exports.empty = empty;
|
||||
/**
|
||||
* Get number of elements of a container.
|
||||
*
|
||||
* @param source Target container.
|
||||
* @return The number of elements in the container.
|
||||
*/
|
||||
function size(source) {
|
||||
if (source instanceof Array)
|
||||
return source.length;
|
||||
else
|
||||
return source.size();
|
||||
}
|
||||
exports.size = size;
|
||||
function distance(first, last) {
|
||||
if (first.index instanceof Function)
|
||||
return _Distance_via_index(first, last);
|
||||
var ret = 0;
|
||||
for (; !first.equals(last); first = first.next())
|
||||
++ret;
|
||||
return ret;
|
||||
}
|
||||
exports.distance = distance;
|
||||
function _Distance_via_index(first, last) {
|
||||
var x = first.index();
|
||||
var y = last.index();
|
||||
if (first.base instanceof Function)
|
||||
return x - y;
|
||||
else
|
||||
return y - x;
|
||||
}
|
||||
function advance(it, n) {
|
||||
if (n === 0)
|
||||
return it;
|
||||
else if (it.advance instanceof Function)
|
||||
return it.advance(n);
|
||||
var stepper;
|
||||
if (n < 0) {
|
||||
if (!(it.prev instanceof Function))
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.advance(): parametric iterator is not a bi-directional iterator, thus advancing to negative direction is not possible.");
|
||||
stepper = function (it) { return it.prev(); };
|
||||
n = -n;
|
||||
}
|
||||
else
|
||||
stepper = function (it) { return it.next(); };
|
||||
while (n-- > 0)
|
||||
it = stepper(it);
|
||||
return it;
|
||||
}
|
||||
exports.advance = advance;
|
||||
/**
|
||||
* Get previous iterator.
|
||||
*
|
||||
* @param it Iterator to move.
|
||||
* @param n Step to move prev.
|
||||
* @return An iterator moved to prev *n* steps.
|
||||
*/
|
||||
function prev(it, n) {
|
||||
if (n === void 0) { n = 1; }
|
||||
if (n === 1)
|
||||
return it.prev();
|
||||
else
|
||||
return advance(it, -n);
|
||||
}
|
||||
exports.prev = prev;
|
||||
/**
|
||||
* Get next iterator.
|
||||
*
|
||||
* @param it Iterator to move.
|
||||
* @param n Step to move next.
|
||||
* @return Iterator moved to next *n* steps.
|
||||
*/
|
||||
function next(it, n) {
|
||||
if (n === void 0) { n = 1; }
|
||||
if (n === 1)
|
||||
return it.next();
|
||||
else
|
||||
return advance(it, n);
|
||||
}
|
||||
exports.next = next;
|
||||
//# sourceMappingURL=global.js.map
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
export * from "./IForwardIterator";
|
||||
export * from "./IBidirectionalIterator";
|
||||
export * from "./IRandomAccessIterator";
|
||||
export * from "./IReverseIterator";
|
||||
export * from "./IReversableIterator";
|
||||
export * from "./InsertIterator";
|
||||
export * from "./FrontInsertIterator";
|
||||
export * from "./BackInsertIterator";
|
||||
export * from "./factory";
|
||||
export * from "./global";
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
// <iterator>
|
||||
//
|
||||
// @reference http://www.cplusplus.com/reference/iterator
|
||||
// @author Jeongho Nam - https://github.com/samchon
|
||||
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 });
|
||||
__exportStar(require("./IForwardIterator"), exports);
|
||||
__exportStar(require("./IBidirectionalIterator"), exports);
|
||||
__exportStar(require("./IRandomAccessIterator"), exports);
|
||||
__exportStar(require("./IReverseIterator"), exports);
|
||||
__exportStar(require("./IReversableIterator"), exports);
|
||||
__exportStar(require("./InsertIterator"), exports);
|
||||
__exportStar(require("./FrontInsertIterator"), exports);
|
||||
__exportStar(require("./BackInsertIterator"), exports);
|
||||
__exportStar(require("./factory"), exports);
|
||||
__exportStar(require("./global"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
Reference in New Issue
Block a user