Quantum Fog  0.9.3
VECTOR.h
1 //******************************************
2 // Purpose: To define an array list.
3 // The list will dwell in the heap.
4 //******************************************
5 #pragma once
6 
7 
8 #include <stdlib.h>//contains exit()
9 
10 //Ref. on template friends: post on newsgroups by Dave Meyer
11 
12 //forward class declaration of template
13 template<class TYPE> class VECTOR;
14 //forward function declaration of friend to be
15 template<class TYPE> BOOLEAN operator!=(const VECTOR<TYPE> & s1, const VECTOR<TYPE> & s2);
16 template<class TYPE> BOOLEAN operator==(const VECTOR<TYPE> & s1, const VECTOR<TYPE> & s2);
17 
18 #ifdef _mac_gui_app //''''''''''''''''''''''''''''''''''''''''''''\\.
19  template<class TYPE> LStream & operator<<(LStream & out_bd, const VECTOR<TYPE> & v);
20  template<class TYPE> LStream & operator>>(LStream & in_bd, VECTOR<TYPE> & v);
21 #endif //_mac_gui_app \\............................................//
22 
23 //******************************************
24 template<class TYPE>
25 class VECTOR
26 {
27 protected:
28  TYPE * its_array_p;
29  USHORT its_len; // len = length
30 public:
31  VOID clear();
32  VOID copy( const VECTOR<TYPE> & s);
33  VOID set_to_default_vec(const TYPE & default_value, USHORT len);
34  VOID resize(const TYPE & default_value, USHORT new_len );
35  VECTOR();
36  VECTOR(const TYPE & default_value, USHORT len);
37  VECTOR( const VECTOR<TYPE> & s );
38  VECTOR<TYPE> & operator=( const VECTOR<TYPE> & rhs );
39  virtual ~VECTOR();
40 
41  USHORT get_len() const;
42  USHORT loc_of_target(const TYPE & tar) const;
43  TYPE & operator[](USHORT i) const;
44 
45  VOID insert_last(const TYPE & data);
46  VOID insert_ptr_last( TYPE data);
47 
48  VOID extract_at(USHORT loc);
49 
50 
51  friend BOOLEAN operator==<TYPE>(const VECTOR<TYPE> & s1, const VECTOR<TYPE> & s2);
52  friend BOOLEAN operator!=<TYPE>(const VECTOR<TYPE> & s1, const VECTOR<TYPE> & s2);
53 #ifdef _mac_gui_app //''''''''''''''''''''''''''''''''''''''''''''\\.
54 
55  friend LStream & operator<< <TYPE>( LStream & out_bd, const VECTOR<TYPE> & v);
56  friend LStream & operator>> <TYPE>( LStream & in_bd, VECTOR<TYPE> & v);
57 #endif //_mac_gui_app \\............................................//
58 
59 
60 };
61 
62 
63 //CW likes "VECTOR_FRIENDS.h" in header file
64 //gcc likes "VECTOR_FRIENDS.h" in implemetation file
65 
66 #include "VECTOR_FRIENDS.h"
Definition: VECTOR.h:13