++



     Фотообои для детской тут. |     

, - 2


IntArray, 2.3 ( deque , int ). , , , IntArray PeekbackStack. . (, IntArray, , .) :

#include "IntArray.h"

class PeekbackStack : public IntArray {

private:

const int static bos = -1;

public:

explicit PeekbackStack( int size )

: IntArray( size ), _top( bos ) {}

bool empty() const { return _top == bos; }

bool full() const { return _top == size()-1; }

int top() const { return _top; }

int pop() {

if ( empty() )

/* */ ;

return _ia[ _top-- ];

}

void push( int value ) {

if ( full() )

/* */ ;

_ia[ ++_top ] = value;

}

bool peekback( int index, int &value ) const;

private:

int _top;

};

inline bool

PeekbackStack::

peekback( int index, int &value ) const

{

if ( empty() )

/* */ ;

if ( index < 0 || index > _top )

{

value = _ia[ _top ];

return false;

}

value = _ia[ index ];

return true;

}

, , PeekbackStack, IntArray:

extern void swap( IntArray&, int, int );

PeekbackStack is( 1024 );

// PeekbackStack