Reputation: 1456
What's the difference between List And ListQueue in Dart programming language? If one can perform the same operations on List, what's the use of ListQueue?
Upvotes: 1
Views: 872
Reputation: 71763
A ListQueue
is not a List
. It implements the Queue
interface and offers (amortized) constant time addFirst
/removeFirst
/addLast
/removeLast
operations. A List
can only do that for addLast
/removeLast
. It costs a little extra overhead for each element access, so you shouldn't use a Queue
where a List
would suffice.
The ListQueue
is an implementation class for the abstract Queue
interface. It's based on an underlying list, which is why it's named the way it is (like a HashSet
is named after the way it implements the Set
interface).
Upvotes: 4