Skip to content

Commit 02b3cc4

Browse files
author
Jeongho Nam
committed
Re-publish
2 parents 761333e + fd07bf5 commit 02b3cc4

File tree

7 files changed

+38
-19
lines changed

7 files changed

+38
-19
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"email": "[email protected]",
77
"url": "http://samchon.org"
88
},
9-
"version": "2.2.2",
9+
"version": "2.2.3",
1010
"main": "./index.js",
1111
"typings": "./index.d.ts",
1212
"scripts": {

src/base/container/MapElementVector.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class MapElementVector<Key, T,
3636
{
3737
super();
3838

39+
this.data_ = [];
3940
this.associative_ = associative;
4041
}
4142

src/base/container/SetElementVector.ts

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class SetElementVector<Key,
3434
{
3535
super();
3636

37+
this.data_ = [];
3738
this.associative_ = associative;
3839
}
3940

src/base/container/VectorContainer.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export abstract class VectorContainer<T extends ElemT,
2020
/**
2121
* @hidden
2222
*/
23-
protected data_: T[];
23+
protected data_!: T[];
2424

2525
/* ---------------------------------------------------------
2626
CONSTRUCTORS
@@ -31,7 +31,6 @@ export abstract class VectorContainer<T extends ElemT,
3131
protected constructor()
3232
{
3333
super();
34-
this.data_ = [];
3534
}
3635

3736
/**

src/container/Deque.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ export class Deque<T>
221221
* @inheritDoc
222222
*/
223223
public swap(obj: Deque<T>): void
224+
{
225+
this._Swap(obj);
226+
}
227+
228+
/**
229+
* @hidden
230+
*/
231+
private _Swap(obj: Deque<T>): void
224232
{
225233
// SWAP CONTENTS
226234
[this.matrix_, obj.matrix_] = [obj.matrix_, this.matrix_];
@@ -460,7 +468,7 @@ export class Deque<T>
460468
deque._Insert_to_end(pos, this.end());
461469

462470
// AND SWAP THIS WITH THE TEMP
463-
this.swap(deque);
471+
this._Swap(deque);
464472
}
465473
else
466474
this._Insert_to_middle(pos, first, last);

src/container/Vector.ts

+19-9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export class Vector<T>
2929
*/
3030
public constructor(items: Array<T>);
3131

32+
/**
33+
* @internal
34+
*/
35+
public constructor(items: Array<T>, move: true);
36+
3237
/**
3338
* Copy Constructor
3439
*
@@ -60,21 +65,26 @@ export class Vector<T>
6065
if (args.length === 0)
6166
{
6267
// DEFAULT CONSTRUCTOR
68+
this.data_ = [];
6369
}
64-
else if (args.length === 1 && args[0] instanceof Array)
70+
else if (args[0] instanceof Array)
6571
{
6672
// INITIALIZER CONSTRUCTOR
6773
let array: Array<T> = args[0];
68-
this.data_ = array.slice();
74+
this.data_ = (args[1] === true)
75+
? array
76+
: array.slice();
6977
}
7078
else if (args.length === 1 && args[0] instanceof Vector)
7179
{
7280
// COPY CONSTRUCTOR
73-
this.data_ = (args[0] as Vector<T>).data_.slice();
81+
let v: Vector<T> = args[0];
82+
this.data_ = v.data_.slice();
7483
}
7584
else if (args.length === 2)
7685
{
7786
// ASSIGN CONSTRUCTOR
87+
this.data_ = [];
7888
this.assign(args[0], args[1]);
7989
}
8090
}
@@ -83,14 +93,14 @@ export class Vector<T>
8393
ACCESSORS
8494
--------------------------------------------------------- */
8595
/**
86-
* @internal
96+
* Wrap an array into a vector.
97+
*
98+
* @param data Target array to be wrapped
99+
* @return A vector wrapping the parametric array.
87100
*/
88-
public static _Capsule<T>(data: Array<T>): Vector<T>
101+
public static wrap<T>(data: Array<T>): Vector<T>
89102
{
90-
let ret: Vector<T> = new Vector<T>();
91-
ret.data_ = data;
92-
93-
return ret;
103+
return new Vector(data, true);
94104
}
95105

96106
/**

src/iterator/factory.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function begin<T>(container: Array<T>): Vector.Iterator<T>;
3535
export function begin(container: any): any
3636
{
3737
if (container instanceof Array)
38-
container = Vector._Capsule(container);
38+
container = Vector.wrap(container);
3939

4040
return container.begin();
4141
}
@@ -56,7 +56,7 @@ export function end<T>(container: Array<T>): Vector.Iterator<T>;
5656
export function end(container: any): any
5757
{
5858
if (container instanceof Array)
59-
container = Vector._Capsule(container);
59+
container = Vector.wrap(container);
6060

6161
return container.end();
6262
}
@@ -84,7 +84,7 @@ export function inserter
8484
(container: Array<any> | _IInsert<any>, it: IForwardIterator<any, any>): InsertIterator<any, any>
8585
{
8686
if (container instanceof Array)
87-
container = Vector._Capsule(container);
87+
container = Vector.wrap(container);
8888

8989
return new InsertIterator(container, it);
9090
}
@@ -120,7 +120,7 @@ export function back_inserter<T>
120120
(source: Array<T> | _IPushBack<T>): BackInsertIterator<T, any>
121121
{
122122
if (source instanceof Array)
123-
source = Vector._Capsule(source);
123+
source = Vector.wrap(source);
124124

125125
return new BackInsertIterator(source);
126126
}
@@ -160,7 +160,7 @@ export function rbegin<T>(container: Array<T>): Vector.ReverseIterator<T>;
160160
export function rbegin(source: any): any
161161
{
162162
if (source instanceof Array)
163-
source = Vector._Capsule(source);
163+
source = Vector.wrap(source);
164164

165165
source.rbegin();
166166
}
@@ -183,7 +183,7 @@ export function rend<T>(container: Array<T>): Vector.ReverseIterator<T>;
183183
export function rend(source: any): any
184184
{
185185
if (source instanceof Array)
186-
source = Vector._Capsule(source);
186+
source = Vector.wrap(source);
187187

188188
source.rend();
189189
}

0 commit comments

Comments
 (0)