本文整理匯總了TypeScript中vs/base/common/linkedList.LinkedList類的典型用法代碼示例。如果您正苦於以下問題:TypeScript LinkedList類的具體用法?TypeScript LinkedList怎麽用?TypeScript LinkedList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了LinkedList類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('Push/Iter', function () {
const list = new LinkedList<number>();
list.push(0);
list.push(1);
list.push(2);
assertElements(list, 0, 1, 2);
});
示例2: test
test('Insert/Iter', function () {
const list = new LinkedList<number>();
list.insert(0);
list.insert(1);
list.insert(2);
assertElements(list, 0, 1, 2);
});
示例3: test
test('unshift/toArray', () => {
let list = new LinkedList<string>();
list.unshift('foo');
list.unshift('bar');
list.unshift('far');
list.unshift('boo');
assertElements(list, 'boo', 'far', 'bar', 'foo');
});
示例4:
function assertElements<E>(list: LinkedList<E>, ...elements: E[]) {
// first: assert toArray
assert.deepEqual(list.toArray(), elements);
// second: assert iterator
for (let iter = list.iterator(), element = iter.next(); !element.done; element = iter.next()) {
assert.equal(elements.shift(), element.value);
}
assert.equal(elements.length, 0);
}
示例5: add
public add(callback: Function, context: any = null, bucket?: IDisposable[]): () => void {
if (!this._callbacks) {
this._callbacks = new LinkedList<[Function, any]>();
}
const remove = this._callbacks.push([callback, context]);
if (Array.isArray(bucket)) {
bucket.push({ dispose: remove });
}
return remove;
}
示例6: entries
public entries(): [Function, any][] {
if (!this._callbacks) {
return [];
}
return this._callbacks
? this._callbacks.toArray()
: [];
}
示例7: invoke
public invoke(...args: any[]): any[] {
if (!this._callbacks) {
return undefined;
}
const ret: any[] = [];
const elements = this._callbacks.toArray();
for (const [callback, context] of elements) {
try {
ret.push(callback.apply(context, args));
} catch (e) {
onUnexpectedError(e);
}
}
return ret;
}