The standard library have most of the abstract data types. So why not add a stack class as well?
I want a stack class mainly to make the intent of my code clearer. To essentially capture the LIFO behaviour.And one more question, why is the queue implemented using a doubly linked list and not a circular linked list.
Thats where i find dart's Queue to be most strange. There is really no reason for a queue if you can't capture the FIFO behaviour yes?
Since we can perform both FIFO and LIFO on the current Queue wouldn't it be more appropriate to rename it as a Deque instead.
Since we can perform both FIFO and LIFO on the current Queue wouldn't it be more appropriate to rename it as a Deque instead.
Agree, that would really be much better. Or just LinkedList, but that name is too long :-)
> Not really, but it suggests that it's actually a List, which it isn't. Lists in Dart are intended for random access, and we should keep it that way.
Fair enough. If it implemented List, it would have to have the [] operator, which should really be O(1), and if it didn't implement List, it would be weird if it was called LinkedList.
On the other hand, it really _is_ a linked list, not only a queue (or double ended queue, for that matter). And "linked list" is a common name and noone expect those to support random access.
LT