Add topological sorting.

This commit is contained in:
Oleksii Trekhleb
2018-05-08 19:27:42 +03:00
parent fc53c7de5d
commit e73dc2dfd7
7 changed files with 225 additions and 1 deletions

View File

@@ -62,4 +62,16 @@ describe('Stack', () => {
expect(stack.pop().value).toBe('test2');
expect(stack.pop().value).toBe('test1');
});
it('should be possible to convert stack to array', () => {
const stack = new Stack();
expect(stack.peek()).toBeNull();
stack.push(1);
stack.push(2);
stack.push(3);
expect(stack.toArray()).toEqual([3, 2, 1]);
});
});