Class TopDownStackIterable<T>

  • Type Parameters:
    T - the type of the items on the stack
    All Implemented Interfaces:
    java.lang.Iterable<T>

    public class TopDownStackIterable<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>
    Provides an iterable over a stack that iterates in order from top to bottom.

    Note: Java stacks natively iterate from bottom to top; C# stacks from top to bottom.

    • Constructor Summary

      Constructors 
      Constructor Description
      TopDownStackIterable​(java.util.Stack<T> stack)
      Construct a top-down iterable view of a stack
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<T> iterator()
      Returns an iterator over elements in the stack, starting at the top of stack and proceeding to the bottom
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • TopDownStackIterable

        public TopDownStackIterable​(java.util.Stack<T> stack)
        Construct a top-down iterable view of a stack
        Parameters:
        stack - the stack over which the top-down iterator will iterate
    • Method Detail

      • iterator

        public java.util.Iterator<T> iterator()
        Returns an iterator over elements in the stack, starting at the top of stack and proceeding to the bottom
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Returns:
        a descending Iterator.