From d905ff5c7fb216522e1c50022c8afae5d9d0210b Mon Sep 17 00:00:00 2001 From: Daniel Chappuis Date: Sun, 23 Dec 2018 23:15:39 +0100 Subject: [PATCH] Small changes in Deque and Pair --- src/containers/Deque.h | 60 ++---------------------------------------- src/containers/Pair.h | 1 - 2 files changed, 2 insertions(+), 59 deletions(-) diff --git a/src/containers/Deque.h b/src/containers/Deque.h index a17c50fd..7c4f47d6 100644 --- a/src/containers/Deque.h +++ b/src/containers/Deque.h @@ -172,62 +172,6 @@ class Deque { mLastChunkIndex += halfNbChunksToAdd; } - /* - /// Get the next item in the deque (return false if we have reached the end) - bool getNextItem(size_t& chunkIndex, size_t& itemIndex) const { - - bool isValid = true; - - // If we have reached the last item - if (chunkIndex == mLastChunkIndex && itemIndex == mLastItemIndex) { - isValid = false; - } - - // If we were at the last item of the chunk - if (itemIndex == CHUNK_NB_ITEMS - 1) { - - // Move to the next chunk - chunkIndex++; - itemIndex = 0; - } - else { - - itemIndex++; - } - - return isValid; - } - - /// Get the previous item in the deque (return false if we have reached the front) - bool getPreviousItem(size_t& chunkIndex, size_t& itemIndex) const { - - // If we have reached the first item - if (chunkIndex == mFirstChunkIndex && itemIndex == mFirstItemIndex) { - return false; - } - - // If we were at the first item of the chunk - if (itemIndex == 0) { - - // Move to the previous chunk - chunkIndex--; - itemIndex = CHUNK_NB_ITEMS - 1; - } - else { - - itemIndex--; - } - - return true; - } - /// Return true if the two chunk/item indices are currently valid for the state of the deque - bool areValidIndices(size_t chunkIndex, size_t itemIndex) const { - - return chunkIndex >= mFirstChunkIndex && chunkIndex <= mLastChunkIndex && - itemIndex >= mFirstItemIndex && itemIndex <= mLastItemIndex; - } - */ - public: /// Class Iterator @@ -422,11 +366,11 @@ class Deque { // Release each chunk for (size_t i=0; i < mNbChunks; i++) { - mAllocator.release(static_cast(mChunks[i]), sizeof(T) * CHUNK_NB_ITEMS); + mAllocator.release(mChunks[i], sizeof(T) * CHUNK_NB_ITEMS); } // Release the chunks array - mAllocator.release(static_cast(mChunks), sizeof(T*) * mNbChunks); + mAllocator.release(mChunks, sizeof(T*) * mNbChunks); } /// Add an element at the end of the deque diff --git a/src/containers/Pair.h b/src/containers/Pair.h index c9cb36dc..ddfd4cd2 100644 --- a/src/containers/Pair.h +++ b/src/containers/Pair.h @@ -103,5 +103,4 @@ namespace std { }; } - #endif