RWTPtrDeque man page on IRIX

Man page or keyword search:  
man Server   31559 pages
apropos Keyword Search (all sections)
Output format
IRIX logo
[printable version]



RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

Name
     RWTPtrDeque<T> - Rogue Wave library class

Synopsis
	      #include <rw/tpdeque.h>
	  RWTPtrDeque<T> deq;

Please Note
     RWTPtrDeque requires the Standard C++ Library.

Description
     This class maintains a pointer-based collection of values, implemented as
     a double-ended queue, or deque.  Class T is the type pointed to by the
     items in the collection.

Persistence
     Isomorphic

Example
     In this example, a double-ended queue of ints is exercised.

	      // tpdeque.cpp

	      #include <rw/tpdeque.h>
	  #include <iostream.h>

	      /*

	       * This program partitions integers into even and odd numbers
	   */

	      int main(){

		RWTPtrDeque<int> numbers;

		int n;

									Page 1

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

		cout << "Input an assortment of integers (EOF to end):"

		     << endl;

		while (cin >> n) {

		  if (n % 2 == 0)
		numbers.pushFront(new int(n));
	      else
		numbers.pushBack(new int(n));
	    }

		while (numbers.entries()) {

		  cout << *numbers.first() << endl;
	      delete numbers.popFront();
	    }

		return 0;

	      }

	      Program Input:

	      1 2 3 4 5
	  <eof>

	      Program Output:

	      4
	  2
	  1

									Page 2

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

	  3

Related Classes
     5

     Classes RWTPtrDlist<T>, RWTPtrSlist<T>, and RWTPtrOrderedVector<T> also
     provide a Rogue Wave pointer-based interface to C++-standard sequence
     collections.  Class deque<T*, allocator> is the C++-standard collection
     that serves as the underlying implementation for this class.

Public Typedefs
	      typedef deque<T*, allocator>		     container_type;
	  typedef container_type::iterator		 iterator;
	  typedef container_type::const_iterator	 const_iterator;
	  typedef container_type::size_type		 size_type;
	  typedef container_type::difference_type	 difference_type;
	  typedef T*					 value_type;
	  typedef T*&					 reference;
	  typedef T* const&				 const_reference;

Public Constructors
	      RWTPtrDeque<T>();

     Constructs an empty, double-ended queue.

	      RWTPtrDeque<T>(const deque<T*, allocator>& deq);

     Constructs a double-ended queue by copying all elements of deq.

	      RWTPtrDeque<T>(const RWTPtrDeque<T>& rwdeq);

     Copy constructor.

	      RWTPtrDeque<T>(size_type n, T* a);

     Constructs a double-ended queue with n elements, each initialized to a.

	      RWTPtrDeque<T>(T* const* first, T* const* last);

     Constructs a double-ended queue by copying elements from the array of T*s
     pointed to by first, up to, but not including, the element pointed to by
     last.

									Page 3

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

Public Member Operators
	      RWTPtrDeque<T>&
	  operator=(const RWTPtrDeque<T>& deq);

     Clears all elements of self and replaces them by copying all elements of
     deq.

	      RWTPtrDeque<T>&
	  operator=(const deque<T*, allocator>& stddeq);

     Clears all elements of self and replaces them by copying all elements of
     stddeq.

	      bool
	  operator<(const RWTPtrDeque<T>& deq);

     Returns true if self compares lexicographically less than deq, otherwise
     returns false.  Items in each collection are dereferenced before being
     compared.	Assumes that type T has well-defined less-than semantics.

	      bool
	  operator==(const RWTPtrDeque<T>& deq);

     Returns true if self compares equal to deq, otherwise returns false.  Two
     collections are equal if both have the same number of entries, and
     iterating through both collections produces, in turn, individual elements
     that compare equal to each other.	Elements are dereferenced before being
     compared.

	      reference
	  operator()(size_type i);
	  const_reference
	  operator()(size_type i) const;

     Returns a reference to the ith element of self.  Index i should be
     between 0 and one less then the number of entries, otherwise the results
     are undefined--no bounds checking is performed.

	      reference
	  operator[](size_type i);
	  const_reference
	  operator[](size_type i) const;

									Page 4

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

     Returns a reference to the ith element of self.  Index i must be between
     0 and one less then the number of entries in self,	 otherwise the
     function throws an exception of type RWBoundsErr.

Public Member Functions
	      void
	  append(T* a);

     Adds the item a to the end of the collection.

	      void
	  apply(void (*fn)(T*,void*), void* d);
	  void
	  apply(void (*fn)(const T*,void*), void* d) const;
	  void
	  apply(void (*fn)(T*&,void*), void* d);

     Applies the user-defined function pointed to by fn to every item in the
     collection.  This function must have one of the prototypes:

		 void yourfun(T* a, void* d);

		 void yourfun(const T* a, void* d);
	     void yourfun(T*& a, void* d);

     for reference semantics.  Client data may be passed through parameter d.

	      reference
	  at(size_type i);
	  const_reference
	  at(size_type i) const;

     Returns a reference to the ith element of self.  Index i must be between
     0 and one less then the number of entries in self, otherwise the function
     throws an exception of type RWBoundsErr.

	      iterator
	  begin();
	  const_iterator
	  begin() const;

     Returns an iterator positioned at the first element of self.

									Page 5

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

	      void
	  clear();

     Clears the collection by removing all items from self.

	      void
	  clearAndDestroy();

     Removes all items from the collection and uses operator delete to destroy
     the objects pointed to by those items.  Do not use this method if
     multiple pointers to the same object are stored.

	      bool
	  contains (const T* a) const;

     If there exists an element t in self such that the expression (*t == *a)
     is true, returns true. Otherwise, returns false.

	      bool
	  contains (bool (*fn)(const T*, void*), void *d) const;
	  bool
	  contains(bool (*fn)(T*,void*), void* d) const;

     Returns true if there exists an element t in self such that the
     expression ((*fn)(t,d)) is true, otherwise returns false.	fn points to a
     user-defined tester function which must have one of the prototypes:

		 bool yourTester(T* a, void* d);

		 bool yourTester(const T* a, void *d)

     Client data may be passed through parameter d.

	      iterator
	  end();
	  const_iterator
	  end() const;

     Returns an iterator positioned "just past" the last element in self.

	      size_type
	  entries() const;

     Returns the number of items in self.

									Page 6

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

	      T*
	  find(const T* a) const;

     If there exists an element t in self such that the expression (*t == *a)
     is true, returns t.  Otherwise, returns rwnil.

	      T*
	  find(bool (*fn)( T*,void*), void* d) const;
	  T*
	  find(bool (*fn)(const T*,void*), void* d) const;

     If there exists an element t in self such that the expression
     ((*fn)(t,d)) is true, returns t.  Otherwise, returns rwnil.  fn points to
     a user-defined tester function which must have one of the prototypes:

		 bool yourTester(T* a, void* d);

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      reference
	  first();
	  const_reference
	  first() const;

     Returns a reference to the first element of self.	If the collection is
     empty, the function throws an exception of type RWBoundsErr.

	      size_type
	  index(const T* a) const;

     Returns the position of the first item t in self such that (*t == *a), or
     returns the static member npos if no such item exists.

	      size_type
	  index(bool (*fn)(T*,void*), void* d) const;
	  size_type
	  index(bool (*fn)(const T*,void*), void* d) const;

     Returns the position of the first item t in self such that((*fn)(t,d)) is
     true, or returns the static member npos if no such item exists.  fn
     points to a user-defined tester function which must have one of the
     prototypes:

									Page 7

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

		 bool yourTester(T* a, void* d);

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      bool
	  insert(T* a);

     Adds the item a to the end of the collection.  Returns true.

	      void
	  insertAt(size_type i, T* a);

     Inserts the item a in front of the item at position i in self.  This
     position must be between zero and the number of entries in the
     collection, otherwise the function throws an exception of type
     RWBoundsErr.

	      bool
	  isEmpty() const;

     Returns true if there are no items in the collection, false otherwise.

	      T*&
	  last();
	  T* const &
	  last() const;

     Returns a reference to the last element of self.

	      reference
	  maxElement();
	  const_reference
	  maxElement() const;
	  reference
	  minElement();
	  const_reference
	  minElement() const;

     Returns a reference to the maximum or minimum element in self.

	      size_type
	  occurrencesOf(const T* a) const;

									Page 8

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

     Returns the number of elements t in self such that the expression (*t ==
     *a) is true.

	      size_type
	  occurrencesOf(bool (*fn)(T*,void*), void* d) const;
	  size_type
	  occurrencesOf(bool (*fn)(const T*,void*), void* d) const;

     Returns the number of elements t in self such that the
     expression((*fn)(t,d)) is true.  fn points to a user-defined tester
     function which must have one of the prototypes:

		 bool yourTester(T* a, void* d);

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      T*
	  popBack();

     Removes and returns the last item in the collection.

	      T*
	  popFront();

     Removes and returns the first item in the collection.

	      void
	  prepend(T* a);

     Adds the item a to the beginning of the collection.

	      void
	  pushBack(T* a);

     Adds the item a to the end of the collection.

	      void
	  pushFront(T* a);

     Adds the item a to the beginning of the collection.

									Page 9

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

	      T*
	  remove(const T* a);

     Removes and returns the first element t in self such that the expression
     (*t == *a) is true.  Returns rwnil if there is no such element.

	      T*
	  remove(bool (*fn)(T*, void*), void* d);
	  T*
	  remove(bool (*fn)(const T*,void*), void* d);

     Removes and returns the first element t in self such that the expression
     ((*fn)(t,d)) is true.  Returns rwnil if there is no such element.	fn
     points to a user-defined tester function which must have one of the
     prototypes:

		 bool yourTester(T* a, void* d);

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      size_type const T*
	  removeAll(const_reference a);

     Removes all elements t in self such that the expression (*t == *a) is
     true.  Returns the number of items removed.

	      size_type
	  removeAll(bool (*fn)(T*,void*), void* d);
	  size_type
	  removeAll(bool (*fn)(const T*,void*), void* d);

     Removes all elements t in self such that the expression ((*fn)(t,d))is
     true.  Returns the number of items removed.  fn points to a user-defined
     tester function which must have one of the prototypes:

		 bool yourTester(T* a, void* d);

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

								       Page 10

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

	      T*
	  removeAt(size_type i);

     Removes and returns the item at position i in self.  This position must
     be between zero and one less then the number of entries in the
     collection, otherwise the function throws an exception of type
     RWBoundsErr.

	      T*
	  removeFirst();

     Removes and returns the first item in the collection.

	      T*
	  removeLast();

     Removes and returns the first item in the collection.

	      size_type
	  replaceAll(const T* oldVal, T* newVal);

     Replaces with newVal all elements t in self such that the expression (*t
     == *oldVal) is true.  Returns the number of items replaced.

	      size_type
	  replaceAll(bool (*fn)(T*, void*), void* x, T* newVal);
	  size_type
	  replaceAll(bool (*fn)(const T*, void*), void* x,
		     const T* newVal);

     Replaces with newVal all elements t in self such that the expression
     ((*fn)(t,d))is true.  Returns the number of items replaced.  fn points to
     a user-defined tester function which must have one of the prototypes:

		 bool yourTester(T* a, void* d);

		 bool yourTester(const T* a, void* d);

     Client data may be passed through parameter d.

	      void
	  sort();

     Sorts the collection using the less-than operator to compare elements.

								       Page 11

RWTPtrDeque(3C++)					     RWTPtrDeque(3C++)

     Elements are dereferenced before being compared.

	      deque<T*, allocator>&
	  std();
	  const deque<T*, allocator>&
	  std() const;

     Returns a reference to the underlying C++-standard collection that serves
     as the implementation for self.

Static Public Data Member
	      size_type	 npos;

     This is the value returned by member functions such as index to indicate
     a non-position.  The value is equal to ~(size_type)0.

Related Global Operators
	      RWvostream&
	  operator<<(RWvostream& strm, const RWTPtrDeque<T>& coll);
	  RWFile&
	  operator<<(RWFile& strm, const RWTPtrDeque<T>& coll);

     Saves the collection coll onto the output stream strm, or a reference to
     it if it has already been saved.

	      RWvistream&
	  operator>>(RWvistream& strm, RWTPtrDeque<T>& coll);
	  RWFile&
	  operator>>(RWFile& strm, RWTPtrDeque<T>& coll);

     Restores the contents of the collection coll from the input stream strm.

	      RWvistream&
	  operator>>(RWvistream& strm, RWTPtrDeque<T>*& p);
	  RWFile&
	  operator>>(RWFile& strm, RWTPtrDeque<T>*& p);

     Looks at the next object on the input stream strm and either creates a
     new collection off the heap and sets p to point to it, or sets p to point
     to a previously read instance.  If a collection is created off the heap,
     then you are responsible for deleting it.

								       Page 12

[top]

List of man pages available for IRIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net