From 33f321f97182b61a044e8508c2014ad7ce2bdec6 Mon Sep 17 00:00:00 2001 From: nvalimak Date: Fri, 9 Jan 2009 13:34:01 +0000 Subject: [PATCH] added new file git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/TextCollection@46 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- BlockArray.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 BlockArray.h diff --git a/BlockArray.h b/BlockArray.h new file mode 100644 index 0000000..cc60c35 --- /dev/null +++ b/BlockArray.h @@ -0,0 +1,50 @@ +#ifndef _BLOCK_ARRAY_H_ +#define _BLOCK_ARRAY_H_ +#include +#include "Tools.h" + +class BlockArray +{ +private: + ulong* data; + ulong n; + ulong index; + ulong blockLength; +public: + BlockArray(ulong len, ulong blockLen) { + n = len; + blockLength = blockLen; + data = new ulong[n*blockLength/W +1]; + } + ~BlockArray() { + delete [] data; + } + + BlockArray& operator[](ulong i) { + index = i; + return *this; + } + + void operator=(const ulong x) { + Tools::SetField(data,blockLength,index,x); + } + + BlockArray& operator=(const BlockArray& ba) { + if (this == &ba) return *this; + ulong value = Tools::GetField(ba.data, ba.blockLength, ba.index); + Tools::SetField(data,blockLength,index,value); + return *this; + } + + operator ulong() { + return Tools::GetField(data,blockLength,index); + } + + ulong spaceInBits() { + return n*blockLength+W; // plus 4 ulong's + } + +}; + +#endif + -- 2.17.1