コード例 #1
0
ファイル: DataMap.cs プロジェクト: kaaLabs15/LoRa
 public void AddFirst(DataBlock block)
 {
     if (this._firstBlock == null)
         this.AddBlockToEmptyMap(block);
     else
         this.AddBeforeInternal(this._firstBlock, block);
 }
コード例 #2
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 private void AddBlockToEmptyMap(DataBlock block)
 {
     block._map = this;
     block._nextBlock = null;
     block._previousBlock = null;
     this._firstBlock = block;
     this._version++;
     this._count++;
 }
コード例 #3
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 private void AddAfterInternal(DataBlock block, DataBlock newBlock)
 {
     newBlock._previousBlock = block;
     newBlock._nextBlock = block._nextBlock;
     newBlock._map = this;
     if (block._nextBlock != null)
     {
         block._nextBlock._previousBlock = newBlock;
     }
     block._nextBlock = newBlock;
     this._version++;
     this._count++;
 }
コード例 #4
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 private void AddBeforeInternal(DataBlock block, DataBlock newBlock)
 {
     newBlock._nextBlock = block;
     newBlock._previousBlock = block._previousBlock;
     newBlock._map = this;
     if (block._previousBlock != null)
     {
         block._previousBlock._nextBlock = newBlock;
     }
     block._previousBlock = newBlock;
     if (this._firstBlock == block)
     {
         this._firstBlock = newBlock;
     }
     this._version++;
     this._count++;
 }
コード例 #5
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 public DataBlock Replace(DataBlock block, DataBlock newBlock)
 {
     this.AddAfterInternal(block, newBlock);
     this.RemoveInternal(block);
     return newBlock;
 }
コード例 #6
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 private void RemoveInternal(DataBlock block)
 {
     DataBlock block2 = block._previousBlock;
     DataBlock block3 = block._nextBlock;
     if (block2 != null)
     {
         block2._nextBlock = block3;
     }
     if (block3 != null)
     {
         block3._previousBlock = block2;
     }
     if (this._firstBlock == block)
     {
         this._firstBlock = block3;
     }
     this.InvalidateBlock(block);
     this._count--;
     this._version++;
 }
コード例 #7
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 public void Remove(DataBlock block)
 {
     this.RemoveInternal(block);
 }
コード例 #8
0
ファイル: DataMap.cs プロジェクト: luyang14/LoRa-1
 private void InvalidateBlock(DataBlock block)
 {
     block._map           = (DataMap)null;
     block._nextBlock     = (DataBlock)null;
     block._previousBlock = (DataBlock)null;
 }
コード例 #9
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 public void AddLast(DataBlock block)
 {
     if (this._firstBlock == null)
     {
         this.AddBlockToEmptyMap(block);
     }
     else
     {
         this.AddAfterInternal(this.GetLastBlock(), block);
     }
 }
コード例 #10
0
ファイル: DataMap.cs プロジェクト: luyang14/LoRa-1
 public void AddBefore(DataBlock block, DataBlock newBlock)
 {
     this.AddBeforeInternal(block, newBlock);
 }
コード例 #11
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 void IEnumerator.Reset()
 {
     if (this._version != this._map._version)
     {
         throw new InvalidOperationException("Collection was modified after the enumerator was instantiated.");
     }
     this._index = -1;
     this._current = null;
 }
コード例 #12
0
ファイル: DataMap.cs プロジェクト: kaaLabs15/LoRa
 public bool MoveNext()
 {
     if (this._version != this._map._version)
         throw new InvalidOperationException("Collection was modified after the enumerator was instantiated.");
     if (this._index >= this._map.Count)
         return false;
     this._current = ++this._index != 0 ? this._current.NextBlock : this._map.FirstBlock;
     return this._index < this._map.Count;
 }
コード例 #13
0
ファイル: DataMap.cs プロジェクト: kaaLabs15/LoRa
 private void RemoveInternal(DataBlock block)
 {
     DataBlock dataBlock1 = block._previousBlock;
     DataBlock dataBlock2 = block._nextBlock;
     if (dataBlock1 != null)
         dataBlock1._nextBlock = dataBlock2;
     if (dataBlock2 != null)
         dataBlock2._previousBlock = dataBlock1;
     if (this._firstBlock == block)
         this._firstBlock = dataBlock2;
     this.InvalidateBlock(block);
     --this._count;
     ++this._version;
 }
コード例 #14
0
ファイル: DataMap.cs プロジェクト: kaaLabs15/LoRa
 private void AddBeforeInternal(DataBlock block, DataBlock newBlock)
 {
     newBlock._nextBlock = block;
     newBlock._previousBlock = block._previousBlock;
     newBlock._map = this;
     if (block._previousBlock != null)
         block._previousBlock._nextBlock = newBlock;
     block._previousBlock = newBlock;
     if (this._firstBlock == block)
         this._firstBlock = newBlock;
     ++this._version;
     ++this._count;
 }
コード例 #15
0
 private FileDataBlock GetNextFileDataBlock(DataBlock block, long dataOffset, out long nextDataOffset)
 {
     nextDataOffset = dataOffset + block.Length;
     block = block.NextBlock;
     while (block != null)
     {
         FileDataBlock block2 = block as FileDataBlock;
         if (block2 != null)
         {
             return block2;
         }
         nextDataOffset += block.Length;
         block = block.NextBlock;
     }
     return null;
 }
コード例 #16
0
ファイル: DataMap.cs プロジェクト: luyang14/LoRa-1
 public void Remove(DataBlock block)
 {
     this.RemoveInternal(block);
 }
コード例 #17
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 internal Enumerator(DataMap map)
 {
     this._map = map;
     this._version = map._version;
     this._current = null;
     this._index = -1;
 }
コード例 #18
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 public bool MoveNext()
 {
     if (this._version != this._map._version)
     {
         throw new InvalidOperationException("Collection was modified after the enumerator was instantiated.");
     }
     if (this._index >= this._map.Count)
     {
         return false;
     }
     if (++this._index == 0)
     {
         this._current = this._map.FirstBlock;
     }
     else
     {
         this._current = this._current.NextBlock;
     }
     return (this._index < this._map.Count);
 }
コード例 #19
0
ファイル: DataMap.cs プロジェクト: luyang14/LoRa-1
 public void AddAfter(DataBlock block, DataBlock newBlock)
 {
     this.AddAfterInternal(block, newBlock);
 }
コード例 #20
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 public void AddAfter(DataBlock block, DataBlock newBlock)
 {
     this.AddAfterInternal(block, newBlock);
 }
コード例 #21
0
 public void WriteByte(long index, byte value)
 {
     try
     {
         long            blockOffset;
         DataBlock       dataBlock        = GetDataBlock(index, out blockOffset);
         MemoryDataBlock memoryDataBlock1 = dataBlock as MemoryDataBlock;
         if (memoryDataBlock1 != null)
         {
             memoryDataBlock1.Data[index - blockOffset] = value;
         }
         else
         {
             FileDataBlock fileDataBlock1 = (FileDataBlock)dataBlock;
             if (blockOffset == index && dataBlock.PreviousBlock != null)
             {
                 MemoryDataBlock memoryDataBlock2 = dataBlock.PreviousBlock as MemoryDataBlock;
                 if (memoryDataBlock2 != null)
                 {
                     memoryDataBlock2.AddByteToEnd(value);
                     fileDataBlock1.RemoveBytesFromStart(1L);
                     if (fileDataBlock1.Length != 0L)
                     {
                         return;
                     }
                     _dataMap.Remove((DataBlock)fileDataBlock1);
                     return;
                 }
             }
             if (blockOffset + fileDataBlock1.Length - 1L == index && dataBlock.NextBlock != null)
             {
                 MemoryDataBlock memoryDataBlock2 = dataBlock.NextBlock as MemoryDataBlock;
                 if (memoryDataBlock2 != null)
                 {
                     memoryDataBlock2.AddByteToStart(value);
                     fileDataBlock1.RemoveBytesFromEnd(1L);
                     if (fileDataBlock1.Length != 0L)
                     {
                         return;
                     }
                     _dataMap.Remove((DataBlock)fileDataBlock1);
                     return;
                 }
             }
             FileDataBlock fileDataBlock2 = (FileDataBlock)null;
             if (index > blockOffset)
             {
                 fileDataBlock2 = new FileDataBlock(fileDataBlock1.FileOffset, index - blockOffset);
             }
             FileDataBlock fileDataBlock3 = (FileDataBlock)null;
             if (index < blockOffset + fileDataBlock1.Length - 1L)
             {
                 fileDataBlock3 = new FileDataBlock(fileDataBlock1.FileOffset + index - blockOffset + 1L, fileDataBlock1.Length - (index - blockOffset + 1L));
             }
             DataBlock block = _dataMap.Replace(dataBlock, (DataBlock) new MemoryDataBlock(value));
             if (fileDataBlock2 != null)
             {
                 _dataMap.AddBefore(block, (DataBlock)fileDataBlock2);
             }
             if (fileDataBlock3 == null)
             {
                 return;
             }
             _dataMap.AddAfter(block, (DataBlock)fileDataBlock3);
         }
     }
     finally
     {
         OnChanged(EventArgs.Empty);
     }
 }
コード例 #22
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 public void AddBefore(DataBlock block, DataBlock newBlock)
 {
     this.AddBeforeInternal(block, newBlock);
 }
コード例 #23
0
 public void WriteByte(long index, byte value)
 {
     try
     {
         long            num;
         DataBlock       dataBlock = this.GetDataBlock(index, out num);
         MemoryDataBlock block2    = dataBlock as MemoryDataBlock;
         if (block2 != null)
         {
             block2.Data[(int)((IntPtr)(index - num))] = value;
         }
         else
         {
             FileDataBlock block = (FileDataBlock)dataBlock;
             if ((num == index) && (dataBlock.PreviousBlock != null))
             {
                 MemoryDataBlock previousBlock = dataBlock.PreviousBlock as MemoryDataBlock;
                 if (previousBlock != null)
                 {
                     previousBlock.AddByteToEnd(value);
                     block.RemoveBytesFromStart(1L);
                     if (block.Length == 0L)
                     {
                         this._dataMap.Remove(block);
                     }
                     return;
                 }
             }
             if ((((num + block.Length) - 1L) == index) && (dataBlock.NextBlock != null))
             {
                 MemoryDataBlock nextBlock = dataBlock.NextBlock as MemoryDataBlock;
                 if (nextBlock != null)
                 {
                     nextBlock.AddByteToStart(value);
                     block.RemoveBytesFromEnd(1L);
                     if (block.Length == 0L)
                     {
                         this._dataMap.Remove(block);
                     }
                     return;
                 }
             }
             FileDataBlock newBlock = null;
             if (index > num)
             {
                 newBlock = new FileDataBlock(block.FileOffset, index - num);
             }
             FileDataBlock block7 = null;
             if (index < ((num + block.Length) - 1L))
             {
                 block7 = new FileDataBlock(((block.FileOffset + index) - num) + 1L, block.Length - ((index - num) + 1L));
             }
             dataBlock = this._dataMap.Replace(dataBlock, new MemoryDataBlock(value));
             if (newBlock != null)
             {
                 this._dataMap.AddBefore(dataBlock, newBlock);
             }
             if (block7 != null)
             {
                 this._dataMap.AddAfter(dataBlock, block7);
             }
         }
     }
     finally
     {
         this.OnChanged(EventArgs.Empty);
     }
 }
コード例 #24
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 public void Clear()
 {
     DataBlock nextBlock;
     for (DataBlock block = this.FirstBlock; block != null; block = nextBlock)
     {
         nextBlock = block.NextBlock;
         this.InvalidateBlock(block);
     }
     this._firstBlock = null;
     this._count = 0;
     this._version++;
 }
コード例 #25
0
ファイル: DataMap.cs プロジェクト: JamesH001/SX1231
 private void InvalidateBlock(DataBlock block)
 {
     block._map = null;
     block._nextBlock = null;
     block._previousBlock = null;
 }
コード例 #26
0
 private FileDataBlock GetNextFileDataBlock(DataBlock block, long dataOffset, out long nextDataOffset)
 {
     nextDataOffset = dataOffset + block.Length;
     for (block = block.NextBlock; block != null; block = block.NextBlock)
     {
         FileDataBlock fileDataBlock = block as FileDataBlock;
         if (fileDataBlock != null)
             return fileDataBlock;
         nextDataOffset += block.Length;
     }
     return (FileDataBlock)null;
 }
コード例 #27
0
ファイル: DataMap.cs プロジェクト: luyang14/LoRa-1
 public DataBlock Replace(DataBlock block, DataBlock newBlock)
 {
     this.AddAfterInternal(block, newBlock);
     this.RemoveInternal(block);
     return(newBlock);
 }