QNANO
List_Class.h
1 #ifndef QNANO_NEW_LIST_CLASS_DEFINED_H_
2 #define QNANO_NEW_LIST_CLASS_DEFINED_H_
3 
4 #include <vector>
5 #include <iostream>
6 #include <cstdlib>
7 
8 template <class T> class List_Class{
9 public:
10  std::vector<T> list;
11  T & operator[](size_t i){ return list[i];}
12  const T & operator[](size_t i) const{ return list[i];}
13 // T operator[](size_t i) const{ return list[i];}
14  size_t size() const{return list.size();}
15  virtual void resize(size_t i){list.resize(i);}
16  virtual void reserve(size_t i){list.reserve(i);}
17  virtual void push_back(const T &value) { list.push_back(value);}
18  virtual void clear(){list.clear();}
19 // operator T() const{return list;}
20  List_Class<T>& operator= (const std::vector<T> & Tvec){ list=Tvec; return *this;}
21  int find(T element) const;
22  int find_check(T element) const;
23  void add_if_new(T element);
24  void add_if_new_check(T element);
25 };
26 
27 template <class T> class List_Class_NoFind{
28 public:
29  std::vector<T> list;
30  T & operator[](size_t i){ return list[i];}
31  const T & operator[](size_t i) const{ return list[i];}
32 // T operator[](size_t i) const{ return list[i];}
33  size_t size() const{return list.size();}
34  virtual void resize(size_t i){list.resize(i);}
35  virtual void reserve(size_t i){list.reserve(i);}
36  virtual void push_back(const T &value) { list.push_back(value);}
37  virtual void clear(){list.clear();}
38 // operator T() const{return list;}
39  List_Class_NoFind<T>& operator= (const std::vector<T> & Tvec){ list=Tvec; return *this;}
40  void add_if_new(T element);
41  void add_if_new_check(T element);
42 };
43 
44 
45 #endif
Definition: List_Class.h:8
Definition: List_Class.h:27