#ifndef __RWEP_SCNTN_H__
#define __RWEP_SCNTN_H__

/***************************************************************************
 *
 * ep_scntn.h - RW_PCntnr<StdColl,RWColl,DataTypes>
 *
 *     : pointer-based interface components for STL Containers
 *
 * $Id: ep_scntn.h,v 7.23 1996/05/08 00:18:57 kyle Exp $
 *
 * (c) Copyright 1989 - 1996 Rogue Wave Software, Inc.
 * ALL RIGHTS RESERVED
 *
 * The software and information contained herein are proprietary to, and
 * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
 * intends to preserve as trade secrets such software and information.
 * This software is furnished pursuant to a written license agreement and
 * may be used, copied, transmitted, and stored only in accordance with
 * the terms of such license and with the inclusion of the above copyright
 * notice.  This software and information or any other copies thereof may
 * not be provided or otherwise made available to any other person.
 *
 * Notwithstanding any other lease or license that may pertain to, or
 * accompany the delivery of, this computer software and information, the
 * rights of the Government regarding its use, reproduction and disclosure
 * are as set forth in Section 52.227-19 of the FARS Computer
 * Software-Restricted Rights clause.
 * 
 * Use, duplication, or disclosure by the Government is subject to
 * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
 * Technical Data and Computer Software clause at DFARS 252.227-7013.
 * Contractor/Manufacturer is Rogue Wave Software, Inc.,
 * P.O. Box 2328, Corvallis, Oregon 97339.
 *
 * This computer software and information is distributed with "restricted
 * rights."  Use, duplication or disclosure is subject to restrictions as
 * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
 * Computer Software-Restricted Rights (April 1985)."  If the Clause at
 * 18-52.227-74 "Rights in Data General" is specified in the contract,
 * then the "Alternate III" clause applies.
 *
 ****************************************************************************
 *
 * $Log: ep_scntn.h,v $
 * Revision 7.23  1996/05/08 00:18:57  kyle
 * Added export pragma for Mac code fragments
 *
 * Revision 7.22  1996/02/18 01:40:53  griswolf
 * Replace tabs with spaces, per Rogue Wave standard.
 *
 * Revision 7.21  1996/02/13 12:14:17  jims
 * Small mods to the interface
 *
 * Revision 7.20  1996/01/30 08:07:07  jims
 * Move functions with 'while' statements out-of-line
 *
 * Revision 7.19  1996/01/29 20:04:46  pearson
 * Remove redundant typedef for size_type
 *
 * Revision 7.18  1996/01/24 21:07:41  jims
 * Simplify implementation of otis-stl ptr-based collections
 * by using container<T*> impls instead of container<void*>
 *
 * Revision 7.17  1995/12/20 23:19:20  kevinj
 * External template persistence using RW*Persistor.
 *
 * Revision 7.16  1995/12/15 10:20:46  jims
 * Bring in min_element and max_element member functions from ep_cntnr.h
 * Work around 'no default args in function templtates' problem
 *
 * Revision 7.15  1995/12/14 18:01:21  jims
 * saveOn, restoreFrom now global instead of member functions
 *
 * Revision 7.14  1995/12/12 00:03:06  jims
 * Add RWTExport
 *
 * Revision 7.13  1995/12/11 22:30:41  jims
 * Remove 'Sca' from interior class names
 * Add 'rw_' to global helper classes
 * Change 'muterator' to 'filterator'
 *
 * Revision 7.12  1995/11/13 12:42:45  jims
 * remove nilValue()
 * add value_type version of find
 *
 * Revision 7.11  1995/09/05 21:42:07  jims
 * Change tlyrs.h to tlyrs.str
 *
 * Revision 7.10  1995/08/23  23:44:04  kevinj
 * Changed saveOn and restoreFrom to return bool.
 *
 * Revision 7.9  1995/08/11  23:38:18  kevinj
 * restoreFrom and saveOn for RWFile.
 *
 * Revision 7.8  1995/08/10  23:42:13  kevinj
 * Moved inline functions out of line.
 *
 * Revision 7.8  1995/08/10  23:42:13  kevinj
 * Moved inline functions out of line.
 *
 * Revision 7.7  1995/08/10  21:36:08  kevinj
 * Moved out of line functions to *.cc.
 *
 * Revision 7.6  1995/07/28  23:28:44  kevinj
 * Removed now-unnecessary second find in saveOn().
 *
 * Revision 7.5  1995/07/28  22:01:32  jims
 * include edefs.h
 *
 * Revision 7.4  1995/07/28  17:53:35  kevinj
 * Modified in accordance with Template Persistence Design Document 2.1.
 *
 ****************************************************************************/

#include "rw/ep_cntnr.h"
#include "rw/epersist.h"
#include "rw/edefs.h"
#include "rw/rwerr.h"
#include "rw/toolerr.h"
#include "rw/vstream.h"

#ifdef RW_PRAGMA_EXPORT
#pragma export on
#endif

template <class StdColl, class RWColl, class T>
class RWTExport RW_PCntnr : public RW_PBase<StdColl,RWColl>
{
public:
  typedef RW_PBase<StdColl,RWColl>   base_type;

  typedef StdColl::value_type        value_type;
  typedef StdColl::size_type         size_type;
  typedef StdColl::iterator          iterator;
  typedef StdColl::const_iterator    const_iterator;
  typedef StdColl::reference         reference;
  typedef StdColl::const_reference   const_reference;
  typedef const T*                   const_value;

  typedef rw_deref_compare<less<T>,T>      deref_less;
  typedef rw_deref_compare<equal_to<T>,T>  deref_equal;

  bool  operator==(const RWColl& rwc)   const
  { return entries() == rwc.entries() &&
      equal(begin(), end(), rwc.begin(), deref_equal()); }

  bool  operator<(const RWColl& rwc)   const
  { return lexicographical_compare(begin(), end(), rwc.begin(),
                                   rwc.end(), deref_less()); }

  void apply(void (*fn)(const_value,void*),void *x) const;
  void apply(void (*fn)(value_type,void*),void *x) { base_type::apply(fn,x); }
  void apply(void (*fn)(reference,void*),void *x)  { base_type::apply(fn,x); }

  bool  contains(const_value key) const;
  bool  contains(bool(*fn)(const_value,void*),void* x) const;
  bool  contains(bool(*fn)(value_type,void*),void* x) const
    { return base_type::contains(fn,x); }

  value_type  find(const_value key) const;
  value_type  find(bool (*fn)(const_value,void*), void* x) const;
  value_type  find(bool (*fn)(value_type,void*), void* x) const;

  size_type     index(bool (*fn)(const_value, void*), void* x) const;
  size_type     index(bool (*fn)(value_type, void*), void* x) const
    { return base_type::index(fn,x); }

  size_type     index(const_value key) const;

  size_type   occurrencesOf(const_value key) const;
  size_type   occurrencesOf(bool (*fn)(const_value,void*),void* x) const;
  size_type   occurrencesOf(bool (*fn)(value_type,void*),void* x) const
    { return base_type::occurrencesOf(fn,x);  }
};

#ifdef RW_COMPILE_INSTANTIATE
#include "rw/ep_scntn.cc"
#endif

#ifdef RW_PRAGMA_EXPORT
#pragma export off
#endif

#endif /* __RWEP_SCNTN_H__ */
