intraector
intraector

Reputation: 1456

Difference between List And ListQueue

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

Answers (1)

lrn
lrn

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

Related Questions