-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSampleIMEStructureArray.h
84 lines (66 loc) · 1.91 KB
/
SampleIMEStructureArray.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//////////////////////////////////////////////////////////////////////
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// CSampleIMESampleIMEStructureArray.h
//
// CSampleIMEStructureArray declaration.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#include <vector>
template <class T> class CSampleIMEStructureArray
{
typedef typename std::vector<T> value_type;
typedef const T &CONST_REF;
typedef typename value_type CSampleIMEArray;
typedef typename value_type::iterator CSampleIMEIter;
public:
CSampleIMEStructureArray() : _imeVector()
{
}
explicit CSampleIMEStructureArray(size_t iCount) : _imeVector(iCount)
{
}
CSampleIMEStructureArray(size_t iCount, CONST_REF tVal) : _imeVector(iCount, tVal)
{
}
virtual ~CSampleIMEStructureArray()
{
}
inline CONST_REF GetAt(size_t iIndex) const
{
assert(iIndex <= _imeVector.size());
assert(_imeVector.size() > 0);
return _imeVector[iIndex];
}
inline T &GetAt(size_t iIndex)
{
assert(iIndex <= _imeVector.size());
assert(_imeVector.size() > 0);
return _imeVector[iIndex];
}
void RemoveAt(size_t iIndex, size_t iElements)
{
assert(iIndex <= _imeVector.size());
assert(_imeVector.size() > 0);
CSampleIMEIter beginIter = _imeVector.begin() + iIndex;
CSampleIMEIter lastIter = beginIter + iElements - 1;
_imeVector.erase(beginIter, lastIter);
}
size_t Count() const
{
return _imeVector.size();
}
void Append(const T &tVal)
{
_imeVector.push_back(tVal);
}
void Clear()
{
_imeVector.clear();
}
private:
CSampleIMEArray _imeVector; // the actual array of data
CSampleIMEIter _imeIter;
};