The deque class now fully supports the IList<> and IList interfaces (with the exception of CopyTo() and CopyToArray() which are not implemented yet); implemented a Clear() method; the deque enumerator is now fully functioning (but still missing an out-of-sync check); moved IndexOf() into its own file; wrote several additional unit tests to verify all the new interface methods are working and to keep test coverage at 100%

git-svn-id: file:///srv/devel/repo-conversion/nusu@163 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
Markus Ewald 2009-07-14 20:15:34 +00:00
parent a817f52406
commit 3ee5fdfc67
8 changed files with 713 additions and 94 deletions

View file

@ -23,14 +23,14 @@ namespace Nuclex.Support.Collections {
/// <summary>Appends an item to the end of the double-ended queue</summary>
/// <param name="item">Item that will be appended to the queue</param>
public void AddLast(ItemType item) {
if(this.lastBlockEndIndex < this.blockSize) {
++this.lastBlockEndIndex;
if(this.lastBlockCount < this.blockSize) {
++this.lastBlockCount;
} else { // Need to allocate a new block
this.blocks.Add(new ItemType[this.blockSize]);
this.lastBlockEndIndex = 1;
this.lastBlockCount = 1;
}
this.blocks[this.blocks.Count - 1][this.lastBlockEndIndex - 1] = item;
this.blocks[this.blocks.Count - 1][this.lastBlockCount - 1] = item;
++this.count;
}
@ -137,15 +137,15 @@ namespace Nuclex.Support.Collections {
int blockLength;
// If the lastmost block is full, we need to add another block
if(this.lastBlockEndIndex == this.blockSize) {
if(this.lastBlockCount == this.blockSize) {
this.blocks.Add(new ItemType[this.blockSize]);
this.blocks[lastBlock + 1][0] = this.blocks[lastBlock][this.blockSize - 1];
this.lastBlockEndIndex = 1;
this.lastBlockCount = 1;
blockLength = this.blockSize - 1;
} else {
blockLength = this.lastBlockEndIndex;
++this.lastBlockEndIndex;
blockLength = this.lastBlockCount;
++this.lastBlockCount;
}
// If the insertion point is not in the lastmost block