提交 e076cf40 编写于 作者: J Joao Moreno

add ArraySet

上级 af438340
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
export class ArraySet<T> {
private _elements: T[];
constructor(elements: T[] = []) {
this._elements = elements.slice();
}
set(element: T): void {
this.unset(element);
this._elements.push(element);
}
unset(element: T): void {
const index = this._elements.indexOf(element);
if (index > -1) {
this._elements.splice(index, 1);
}
}
get elements(): T[] {
return this._elements;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册