//================================================================ /** * @packageDocumentation * @module std */ //================================================================ import { InsertIteratorBase } from "../internal/iterator/InsertIteratorBase"; import { IPushBack } from "../internal/container/partial/IPushBack"; import { Vector } from "../container/Vector"; import { equal_to } from "../functional/comparators"; /** * Back insert iterator. * * @author Jeongho Nam - https://github.com/samchon */ export class BackInsertIterator< Source extends IPushBack>, > extends InsertIteratorBase< BackInsertIterator.ValueType, BackInsertIterator > { private source_: Source; /* --------------------------------------------------------- METHODS --------------------------------------------------------- */ /** * Initializer Constructor. * * @param source The source container. */ public constructor(source: Source) { super(); this.source_ = source; } /** * @inheritDoc */ public set value(val: BackInsertIterator.ValueType) { this.source_.push_back(val); } /** * @inheritDoc */ public equals(obj: BackInsertIterator): boolean { return equal_to(this.source_, obj.source_); } } /** * */ export namespace BackInsertIterator { /** * Deduct value type. */ export type ValueType> = Source extends IPushBack ? T : unknown; /** * Deduct source type. */ export type SourceType | IPushBack> = Source extends Array ? Vector : Source; }