本文整理匯總了TypeScript中@phosphor/collections.LinkedList.addFirst方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LinkedList.addFirst方法的具體用法?TypeScript LinkedList.addFirst怎麽用?TypeScript LinkedList.addFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@phosphor/collections.LinkedList
的用法示例。
在下文中一共展示了LinkedList.addFirst方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should add a value to the beginning of the list', () => {
let list = new LinkedList<number>();
expect(list.isEmpty).to.equal(true);
expect(list.length).to.equal(0);
expect(list.first).to.equal(undefined);
expect(list.last).to.equal(undefined);
let n1 = list.addFirst(99);
expect(list.isEmpty).to.equal(false);
expect(list.length).to.equal(1);
expect(list.first).to.equal(99);
expect(list.last).to.equal(99);
let n2 = list.addFirst(42);
expect(list.isEmpty).to.equal(false);
expect(list.length).to.equal(2);
expect(list.first).to.equal(42);
expect(list.last).to.equal(99);
let n3 = list.addFirst(7);
expect(list.isEmpty).to.equal(false);
expect(list.length).to.equal(3);
expect(list.first).to.equal(7);
expect(list.last).to.equal(99);
expect(toArray(list)).to.deep.equal([7, 42, 99]);
expect(n1.list).to.equal(list);
expect(n1.next).to.equal(null);
expect(n1.prev).to.equal(n2);
expect(n1.value).to.equal(99);
expect(n2.list).to.equal(list);
expect(n2.next).to.equal(n1);
expect(n2.prev).to.equal(n3);
expect(n2.value).to.equal(42);
expect(n3.list).to.equal(list);
expect(n3.next).to.equal(n2);
expect(n3.prev).to.equal(null);
expect(n3.value).to.equal(7);
});