ESyS-Particle  2.2
nt_slab.h
Go to the documentation of this file.
1 
2 // //
3 // Copyright (c) 2003-2013 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 #ifndef __NT_SLAB_H
14 #define __NT_SLAB_H
15 
16 //--- project includes ---
17 #include "nts_iter.h"
18 #include "ntable.h"
19 #include "dslice.h"
20 
21 //--- forward decls ---
22 template <typename T>
23 class NTSlab;
24 
25 template <typename T> bool operator==(const NTSlab<T>&,const NTSlab<T>&);
26 template <typename T> bool operator!=(const NTSlab<T>&,const NTSlab<T>&);
27 template <typename T> ostream& operator<<(ostream &, const NTSlab<T> &);
28 
33 template <typename T>
34 class NTSlab
35 {
36  public: // types
38  typedef NTSlab_iter<T> const_iterator; // dodgy
39  typedef T value_type;
40 
41  private:
44 
45 
46  public:
47  NTSlab();
49 
50  unsigned int slab_size()const {return m_sl.size();}
51  unsigned int size()const;
52 
53  // begin and end iterators
54  iterator begin();
55  iterator end();
56 
57  iterator rbegin();
58  iterator rend();
59 
61  unsigned int nparts_at_gridpoint(unsigned int idx) const {return m_table->nparts_at_gridpoint(m_sl[idx]);};
62 
63  // access ops
64  T* ptr(typename NeighborTable<T>::indextype);
65  T& ref(typename NeighborTable<T>::indextype);
66 
67  // insert ops
68  void insert(iterator,const T&);
69 
70  // erase ops
71  void erase(iterator);
72  void erase(iterator,iterator);
73 
74  //comparison
75  friend bool operator== <>(const NTSlab&,const NTSlab&);
76  friend bool operator!= <>(const NTSlab&,const NTSlab&);
77 
78  friend ostream& operator<< <>(ostream &, const NTSlab &);
79 };
80 
81 #include "nt_slab.hpp"
82 
83 #endif //__NT_SLAB_H