         
         return pos
     }
-
+    
+    // basic block methodes
+    subscript(index: UID) -> D! {
+        get {
+            return self.readBlock(index)
+        }
+        
+        set (newValue) {
+            
+            let pos = calculatePos(index)
+            
+            if newValue {
+                if (pos > endOfFile) {
+                    // TODO: error
+                } else {
+                    writeBlock(newValue, atPos: pos)
+                }
+                
+            } else {
+                // newValue = nil -> delete
+                deleteBlock(index)
+            }
+        }
+    }
+    
+    // #pragma mark READ -------------------------------------------------------
+    
+
+    func readBlock(index : UID) -> D! {
+        self.seekToFileID(index)
+        
+        let header = readHeader()
+        if (header.used) {
+            return self.readData()
+        }
+        
+        return nil;
+    }
+    
     // #pragma mark - read/write header
     
     func readHeader() -> H! {


// Concept requirements & implementation

// CRUD D
// - generic data
// - generic header

// D = a data 


class DataStore<H: DataStoreHeader,D: Init>  {
    
    // #pragma mark ----------------------------------------------------------------
    
    // data.length + header.length;
    let headerSize = sizeof(H)
    let dataSize = sizeof(D)
    let blockSize = sizeof(H) + sizeof(D)  // test as CUnsignedLongLong
    
    var error: NSError?  // readonly?
    
    var url: NSURL!
    var fileHandle: NSFileHandle!
    var newFile = false;
    
    var fileOffset : Int = 1  // see createNewFile
    
    var endOfFile: CUnsignedLongLong = 0;
    var unusedDataSegments =  Dictionary<CUnsignedLongLong,Bool>()
