Skip to content

Commit

Permalink
Re-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongho Nam committed Jul 28, 2019
2 parents 761333e + fd07bf5 commit 02b3cc4
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"email": "samchon@samchon.org",
"url": "http://samchon.org"
},
"version": "2.2.2",
"version": "2.2.3",
"main": "./index.js",
"typings": "./index.d.ts",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/base/container/MapElementVector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class MapElementVector<Key, T,
{
super();

this.data_ = [];
this.associative_ = associative;
}

Expand Down
1 change: 1 addition & 0 deletions src/base/container/SetElementVector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class SetElementVector<Key,
{
super();

this.data_ = [];
this.associative_ = associative;
}

Expand Down
3 changes: 1 addition & 2 deletions src/base/container/VectorContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export abstract class VectorContainer<T extends ElemT,
/**
* @hidden
*/
protected data_: T[];
protected data_!: T[];

/* ---------------------------------------------------------
CONSTRUCTORS
Expand All @@ -31,7 +31,6 @@ export abstract class VectorContainer<T extends ElemT,
protected constructor()
{
super();
this.data_ = [];
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/container/Deque.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ export class Deque<T>
* @inheritDoc
*/
public swap(obj: Deque<T>): void
{
this._Swap(obj);
}

/**
* @hidden
*/
private _Swap(obj: Deque<T>): void
{
// SWAP CONTENTS
[this.matrix_, obj.matrix_] = [obj.matrix_, this.matrix_];
Expand Down Expand Up @@ -460,7 +468,7 @@ export class Deque<T>
deque._Insert_to_end(pos, this.end());

// AND SWAP THIS WITH THE TEMP
this.swap(deque);
this._Swap(deque);
}
else
this._Insert_to_middle(pos, first, last);
Expand Down
28 changes: 19 additions & 9 deletions src/container/Vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export class Vector<T>
*/
public constructor(items: Array<T>);

/**
* @internal
*/
public constructor(items: Array<T>, move: true);

/**
* Copy Constructor
*
Expand Down Expand Up @@ -60,21 +65,26 @@ export class Vector<T>
if (args.length === 0)
{
// DEFAULT CONSTRUCTOR
this.data_ = [];
}
else if (args.length === 1 && args[0] instanceof Array)
else if (args[0] instanceof Array)
{
// INITIALIZER CONSTRUCTOR
let array: Array<T> = args[0];
this.data_ = array.slice();
this.data_ = (args[1] === true)
? array
: array.slice();
}
else if (args.length === 1 && args[0] instanceof Vector)
{
// COPY CONSTRUCTOR
this.data_ = (args[0] as Vector<T>).data_.slice();
let v: Vector<T> = args[0];
this.data_ = v.data_.slice();
}
else if (args.length === 2)
{
// ASSIGN CONSTRUCTOR
this.data_ = [];
this.assign(args[0], args[1]);
}
}
Expand All @@ -83,14 +93,14 @@ export class Vector<T>
ACCESSORS
--------------------------------------------------------- */
/**
* @internal
* Wrap an array into a vector.
*
* @param data Target array to be wrapped
* @return A vector wrapping the parametric array.
*/
public static _Capsule<T>(data: Array<T>): Vector<T>
public static wrap<T>(data: Array<T>): Vector<T>
{
let ret: Vector<T> = new Vector<T>();
ret.data_ = data;

return ret;
return new Vector(data, true);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/iterator/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function begin<T>(container: Array<T>): Vector.Iterator<T>;
export function begin(container: any): any
{
if (container instanceof Array)
container = Vector._Capsule(container);
container = Vector.wrap(container);

return container.begin();
}
Expand All @@ -56,7 +56,7 @@ export function end<T>(container: Array<T>): Vector.Iterator<T>;
export function end(container: any): any
{
if (container instanceof Array)
container = Vector._Capsule(container);
container = Vector.wrap(container);

return container.end();
}
Expand Down Expand Up @@ -84,7 +84,7 @@ export function inserter
(container: Array<any> | _IInsert<any>, it: IForwardIterator<any, any>): InsertIterator<any, any>
{
if (container instanceof Array)
container = Vector._Capsule(container);
container = Vector.wrap(container);

return new InsertIterator(container, it);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ export function back_inserter<T>
(source: Array<T> | _IPushBack<T>): BackInsertIterator<T, any>
{
if (source instanceof Array)
source = Vector._Capsule(source);
source = Vector.wrap(source);

return new BackInsertIterator(source);
}
Expand Down Expand Up @@ -160,7 +160,7 @@ export function rbegin<T>(container: Array<T>): Vector.ReverseIterator<T>;
export function rbegin(source: any): any
{
if (source instanceof Array)
source = Vector._Capsule(source);
source = Vector.wrap(source);

source.rbegin();
}
Expand All @@ -183,7 +183,7 @@ export function rend<T>(container: Array<T>): Vector.ReverseIterator<T>;
export function rend(source: any): any
{
if (source instanceof Array)
source = Vector._Capsule(source);
source = Vector.wrap(source);

source.rend();
}

0 comments on commit 02b3cc4

Please sign in to comment.