Saturday, 15 February 2014

data structures - Why there is no interface for stack collection types in the Java standard library? -



data structures - Why there is no interface for stack collection types in the Java standard library? -

queues typically order elements in fifo (first-in-first-out) manner while stacks in lifo (last-in-first-out) manner.

in java standard library there specific interface called queue modelling queue , bunch of classes implementing it.

although there classes implementing stack, stack (which extends vector), arraydeque (which, stated in javadoc, "is faster stack when used stack") , linkedlist (with push , pop methods), there no specific interface stack collection types.

why there no interface stack collection types in java standard library?

the design of interfaces in java implies each class implementing interface declares it.

you can conceive many interfaces many roles can't design, each time, interface, or code starts verbose.

so choices have made. designing lifo interface , having lifo classes declaring wasn't, obviously, seen much important.

java data-structures collections interface

No comments:

Post a Comment