summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-12-08 15:21:37 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-12-08 15:21:37 +0300
commita5bdc9a1a5cf704a0d865f8f87dcc6f68b25532f (patch)
tree7b4c28107dd1f4b3b22ee4ae67aec36a895cbe79
parentabbb9519304b3090fed7d98c8a93524361b329b7 (diff)
HistoryArray::insert
-rw-r--r--plugins/NewStory/src/history_array.cpp17
-rw-r--r--plugins/NewStory/src/history_array.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index c9353e88f0..8065adfb20 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -635,6 +635,23 @@ int HistoryArray::find(int id, int dir, const Filter &filter)
return -1;
}
+ItemData* HistoryArray::insert(int pos)
+{
+ int count = getCount();
+ ItemData *pNew = &allocateItem();
+ ItemData *pPrev = get(count-1, false);
+
+ for (int i = count; i >= pos; i--) {
+ memcpy(pNew, pPrev, sizeof(ItemData));
+ pNew = pPrev;
+ pPrev = get(i - 1, false);
+ }
+
+ ItemData tmp;
+ memcpy(pNew, &tmp, sizeof(tmp));
+ return pNew;
+}
+
void HistoryArray::remove(int id)
{
int pageNo = id / HIST_BLOCK_SIZE;
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index 7ec4168bf5..7e8d01b23d 100644
--- a/plugins/NewStory/src/history_array.h
+++ b/plugins/NewStory/src/history_array.h
@@ -149,6 +149,7 @@ public:
}
ItemData* get(int id, bool bLoad = false) const;
+ ItemData* insert(int idx);
__forceinline int FindNext(int id, const Filter &filter) { return find(id, +1, filter); }
__forceinline int FindPrev(int id, const Filter &filter) { return find(id, -1, filter); }