-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
FrontInsertIterator.ts
58 lines (53 loc) · 1.51 KB
/
FrontInsertIterator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
import { InsertIteratorBase } from "../internal/iterator/InsertIteratorBase";
import { IPushFront } from "../internal/container/partial/IPushFront";
import { equal_to } from "../functional/comparators";
/**
* Front insert iterator.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export class FrontInsertIterator<Source extends IPushFront<FrontInsertIterator.ValueType<Source>>>
extends InsertIteratorBase<FrontInsertIterator.ValueType<Source>, FrontInsertIterator<Source>>
{
private source_: Source;
/* ---------------------------------------------------------
METHODS
--------------------------------------------------------- */
/**
* Initializer Constructor.
*
* @param source The source container.
*/
public constructor(source: Source)
{
super();
this.source_ = source;
}
/**
* @inheritDoc
*/
public set value(val: FrontInsertIterator.ValueType<Source>)
{
this.source_.push_front(val);
}
/**
* @inheritDoc
*/
public equals(obj: FrontInsertIterator<Source>): boolean
{
return equal_to(this.source_, obj.source_);
}
}
export namespace FrontInsertIterator
{
export type ValueType<Source extends IPushFront<any>> =
Source extends IPushFront<infer T>
? T
: unknown;
}