Go to the documentation of this file.
15 #define DynArrayPageConstr_D 0
16 #define DynArrayDestr_D 0
17 #define DynArrayIndex_D 0
30 const uint pgsz,
const uint pgmsk,
31 const bool init =
false);
62 virtual std::ostream&
info(std::ostream& os)
const;
105 class DynArray :
public DynArrayBase {
122 inline DynArray(uint htblsz, uint pgsz,
const T& dflt);
154 virtual std::ostream&
info(std::ostream& os)
const;
163 DynArrayBase(htblsz, (1 << htblsz) - 1, pgsz, (1 << pgsz) - 1, false),
165 for(uint i = htblmsk_ + 1; i--;)
171 DynArrayBase(htblsz, (1 << htblsz) - 1, pgsz, (1 << pgsz) - 1, true),
172 htbl_(new
DynArrayPage<T>*[htblmsk_ + 1]), lru_(0), dflt_(dflt) {
173 for(uint i = htblmsk_ + 1; i--;)
180 lru_(0), dflt_(d.dflt_) {
181 for(uint i = d.htblmsk_ + 1; i--;)
189 for(uint i = htblmsk_ + 1; i--;) {
206 if (lru_ == NULL || i < min_)
209 uint pgidx = i >> pgsz_;
211 if (lru_ != NULL && lru_->index() == pgidx)
212 return (*lru_)[i & pgmsk_];
218 if (pg->index() == pgidx)
219 return (*(lru_ = pg))[i & pgmsk_];
226 for(uint j = pgmsk_ + 1; j--;)
229 return (*(lru_ = pg))[i & pgmsk_];
240 if (lru_ == NULL || i < min_) {
246 uint pgidx = i >> pgsz_;
248 if (lru_ != NULL && lru_->index() == pgidx)
249 return (*lru_)[i & pgmsk_];
255 if (pg->index() == pgidx)
256 return (*pg)[i & pgmsk_];
267 if (!(i < max_))
return 0;
268 if (lru_ == 0 || i < min_)
return 0;
270 uint pgidx = i >> pgsz_;
272 if (lru_ != 0 && lru_->index() == pgidx)
273 return (init_) ? ((*lru_)[i & pgmsk_] != dflt_) : 1;
279 if (pg->index() == pgidx) {
281 return (init_) ? ((*lru_)[i & pgmsk_] != dflt_) : 1;
291 if (!(i < max_))
return 0;
292 if (lru_ == 0 || i < min_)
return 0;
294 uint pgidx = i >> pgsz_;
298 if (lru != 0 && lru->
index() == pgidx)
299 return (init_) ? (&(*lru)[i & pgmsk_] != &dflt_) : 1;
305 if (pg->index() == pgidx) {
307 return (init_) ? ((*lru)[i & pgmsk_] != dflt_) : 1;
316 return sizeof(
DynArray) + (
float)(1 << htblsz_) *
323 for(uint i = htblmsk_ + 1; i--;) {
332 lru_ = NULL; max_ = min_ = 0; npg_ = 0;
337 os <<
concepts::typeOf(*
this)<<
"(init = " << init_ <<
", emtpy = " << empty_
338 <<
", min = " << min_ <<
", max = " << max_ <<
", npg = "
339 << npg_ <<
", htblsz = " << htblsz_ <<
", htblmsk = "
340 << htblmsk_ <<
", pgsz = " << pgsz_ <<
", pgmsk = " << pgmsk_
341 <<
", [" << std::endl;
342 for(uint i = htblmsk_ + 1; i--;) {
345 uint pgidx = pg->
index();
346 os << pgidx <<
" | ";
347 for (uint j = 0; j <= pgmsk_; ++j)
348 os <<
'(' << (pgidx << pgsz_) + j <<
", " << (*pg)[j] <<
"), ";
359 #endif // dynarray_hh
DynArrayPage(uint idx, uint sz, DynArrayPage *lnk=0)
void operator=(DynArrayBase &)
uint max() const
Maximal referenced index + 1.
void init()
Before using conceptspy make sure to call this routine.
#define conceptsException(exc)
Prepares an exception for throwing.
Base class for exceptions.
DynArrayPage(const DynArrayPage &pg)
Copy constructor of the whole queue.
Container class: a dynamic array.
A page of a dynamic array.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const uint pgsz_
Size of a page in number of entries.
T & operator[](uint i)
Index operator for the container.
DynArrayPage * link() const
DynArray(uint htblsz, uint pgsz, const T &dflt)
bool isElm(uint i)
Checks if the element is not equal to the default element.
#define DEBUGL(doit, msg)
virtual std::ostream & info(std::ostream &os) const
float memory() const
Approximate memory consumption in bytes.
DynArrayBase(const DynArrayBase &base)
Copy constructor.
uint min() const
Minimal referenced index.
DynArray(uint htblsz=2, uint pgsz=2)
Constructor.
DynArrayBase(const uint htblsz, const uint htblmsk, const uint pgsz, const uint pgmsk, const bool init=false)
const uint htblmsk_
Hash table mask.
DynArray(const DynArray &d)
Copy constructor.
void reset()
Clears the array.
Exception class to express that an index in a dynamic array does not exist.
const bool isElm(uint i) const
Base class for DynArray for the non-template part.
std::string typeOf(const T &t)
Return the typeid name of a class object.
DynArrayPage< T > ** htbl_
const uint htblsz_
Size of the hash table function (how many bits of the page number)
Class providing an output operator.
#define DynArrayPageConstr_D
Basic namespace for Concepts-2.