home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 9-8.H < prev    next >
C/C++ Source or Header  |  1991-12-04  |  1KB  |  43 lines

  1. /* Copyright (c) 1992 by AT&T Bell Laboratories. */
  2. /* Advanced C++ Programming Styles and Idioms */
  3. /* James O. Coplien */
  4. /* All rights reserved. */
  5.  
  6. template<class T, class S>
  7.     class Array: public CollectionRep<T, S> {
  8.     public:
  9.         Array();
  10.         Array(Array<T, S>&);
  11.         ~Array();
  12.         class Collection<T, S> make();
  13.         class Collection<T, S> make(int size);
  14.         T& operator[](int i);
  15.         void put(const T&);
  16.     private:
  17.         T *vec;
  18.         int size;
  19.     };
  20.  
  21. template<class T>
  22.     struct HashTableElement {
  23.         HashTableElement *next;
  24.         T *element;
  25.     };
  26.  
  27. template<class T, class S>
  28.     class HashTable: public CollectionRep<T, S> {
  29.     public:
  30.         HashTable();
  31.         HashTable(HashTable<T, S>&);
  32.         ~HashTable();
  33.         class Collection<T, S> make();
  34.         class Collection<T, S> make(int);
  35.         T& operator[](int i);
  36.         T& operator[](S);
  37.         void put(const T&);
  38.     private:
  39.         int nbuckets;
  40.         virtual int hash(int l);
  41.         HashTableElement<T> *buckets;
  42.     };
  43.