blob: 7d259a5eb4720c9e254f6520f10f30f3463e3b2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#pragma once
#include "common.h"
#include "LComparator.h"
class AFX_CLASS_EXPORT LArray {
public:
LArray();
LArray(int size, LComparator* comparator = NULL, BOOL keepSorted = false);
void init(int size, LComparator* comparator, BOOL keepSorted);
~LArray();
virtual int GetCount() const;
protected:
void Expand(int amount);
public:
void AdjustAllocation(int amount);
void SetKeepSorted(BOOL keepSorted);
virtual void InsertItemsAt(int count, int where, const void* data);
virtual void RemoveItemsAt(int count, int where);
virtual void Remove(const void* item);
virtual int FetchIndexOf(const void* item) const;
virtual BOOL FetchItemAt(int index, void* outItem) const;
virtual void AssignItemsAt(int count, int where, void* data);
virtual void Add(const void* item);
void SetComparator(LComparator* comparator);
virtual void ReadAsWord(T2Archive& archive);
virtual void WriteAsWord(T2Archive& archive);
virtual void ReadAsDWord(T2Archive& archive);
virtual void WriteAsDWord(T2Archive& archive);
virtual void ReadAsChar(T2Archive& archive);
virtual void WriteAsChar(T2Archive& archive);
protected:
BOOL mOwnsComparator;
int mItemSize;
int mItemCount;
void *mBuffer;
int mExpandSize;
LComparator *mComparator;
BOOL mKeepSorted;
};
class AFX_CLASS_EXPORT LArrayIterator {
public:
LArrayIterator(const LArray& array, int index = 1);
LArrayIterator(const LArrayIterator& iter);
~LArrayIterator();
void ResetTo(int index);
void Rewind();
void Seek(const LArrayIterator& iter);
BOOL Next(void* item);
BOOL Previous(void* item);
void Reset() { ResetTo(1); }
int GetCurrentIndex() { return mCurrentIndex; }
private:
const LArray *mArray;
int mNextIndex;
int mCurrentIndex;
};
|