title: Are all the values on the Stack smaller than a passed value?
body: <p>I am in the middle of completing a Stack program and am unsure how to formulate a method that determines if all the values on the Stack are smaller than the passed value.</p>
  
  <p>So, for example, for a stack containing top- (1) (1) (2) (3) (5) (5) (2), allSmallerThan( 3 ) should return false because there values on the Stack bigger than 3. On the other hand, for a stack containing top- (1) (1) (2) (3) (5) (5) (2), allSmallerThan( 12 ) should return true because all the values on the stack are less than 12.</p>
  
  <p>I have made the operation signature</p>
  
  <pre><code>int Stack&lt;Object&gt;::allSmallerThan( const Object &amp; data ) const; 
  </code></pre>
  
  <p>But after that, I am a bit stumped of where to go</p>
  
  <p>Below is the full implementation file. Most of the file was given to us and we have been asked to complete certain operations. This one in particular is killlling</p>
  
  <pre><code>#ifndef STACK_CPP
  #define STACK_CPP
  
  #include "Stack.h"
  
  namespace cs20 {
  
  template &lt;class Object&gt;
  Stack&lt;Object&gt;::Stack() {
      topNode = NULL;
  }
  
  template &lt;class Object&gt;
  Stack&lt;Object&gt;::Stack( const Stack&lt;Object&gt;&amp; rhs ) {
      topNode = NULL;
      *this = rhs;
  }
  
  template &lt;class Object&gt;
  Stack&lt;Object&gt;::~Stack() {
      makeEmpty();
      delete topNode;
  }
  
  template &lt;class Object&gt;
  bool Stack&lt;Object&gt;::isEmpty() const {
      return( (topNode == NULL) );
  }
  
  template &lt;class Object&gt;
  void Stack&lt;Object&gt;::makeEmpty() {
      while (!isEmpty()) {
          pop();
      }
  }
  template &lt;class Object&gt;
      int Stack&lt;Object&gt;::allSmallerThan( const Object &amp; data ) const{
  
  
      }
  
  
  template &lt;class Object&gt;
  void Stack&lt;Object&gt;::push( const Object&amp; data ) {
      StackNode&lt;Object&gt;* newNode = new StackNode&lt;Object&gt;( data, topNode );
      topNode = newNode;
  }
  
  template &lt;class Object&gt;
  void Stack&lt;Object&gt;::pop() {
      if (isEmpty()) {
          throw EmptyStack();
      }
      StackNode&lt;Object&gt; *oldTop = topNode;
      topNode = topNode-&gt;getNext();
      delete oldTop;
  }
  
  template &lt;class Object&gt;
  const Object&amp; Stack&lt;Object&gt;::top( ) const {
      if (isEmpty()) {
          throw EmptyStack();
      }
      StackNode&lt;Object&gt; node = *topNode;
      return( node.getElement() );
  }
  
  template &lt;class Object&gt;
  Object Stack&lt;Object&gt;::topAndPop( ) {
      Object o = top();
      pop();
      return( o );
  }
  
  // Deep copy of linked Stack
  template &lt;class Object&gt;
  const Stack&lt;Object&gt;&amp; Stack&lt;Object&gt;::operator =( const Stack&lt;Object&gt;&amp; rhs ) {
      if (this != &amp;rhs) {
          makeEmpty();
          if (!(rhs.isEmpty())) {
              StackNode&lt;Object&gt; * rhsTopNode = rhs.topNode;
              StackNode&lt;Object&gt; * myTopNode = new StackNode&lt;Object&gt;( rhsTopNode-&gt;getElement() );
              topNode = myTopNode;
  
              rhsTopNode = rhsTopNode-&gt;getNext();
              while (rhsTopNode != NULL) {
                  myTopNode-&gt;setNext( new StackNode&lt;Object&gt;( rhsTopNode-&gt;getElement() ) );
                  myTopNode = myTopNode-&gt;getNext();
                  rhsTopNode = rhsTopNode-&gt;getNext();
              }
          }
      }
      return( *this );
  }
  
  template &lt;class Object&gt; 
  std::ostream&amp; Stack&lt;Object&gt;::printStack( std::ostream&amp; outs ) const {
      if (isEmpty()) {
          outs &lt;&lt; "Empty Stack";
      }
      else {
          outs &lt;&lt; "TOP: ";
          StackNode&lt;Object&gt; * node = topNode;
          while (node != NULL) {
              outs &lt;&lt; node-&gt;getElement();
              outs &lt;&lt; "\n     ";           /// for visual alignment
              node = node-&gt;getNext();
          }
      }
      return( outs );
  }
  
  }
  
  #endif
  </code></pre>
  
  <p>All the best
  Thanks!</p>