added new file
authornvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Fri, 9 Jan 2009 13:34:01 +0000 (13:34 +0000)
committernvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Fri, 9 Jan 2009 13:34:01 +0000 (13:34 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/TextCollection@46 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

BlockArray.h [new file with mode: 0644]

diff --git a/BlockArray.h b/BlockArray.h
new file mode 100644 (file)
index 0000000..cc60c35
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _BLOCK_ARRAY_H_
+#define _BLOCK_ARRAY_H_
+#include <iostream>
+#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
+