ReactOS 0.4.15-dev-8408-g466a198
CicArrayBase Class Reference

#include <cicarray.h>

Inheritance diagram for CicArrayBase:

Public Member Functions

 CicArrayBase (size_t cbItem)
 
virtual ~CicArrayBase ()
 
BOOL Insert (size_t iItem, size_t cGrow)
 
LPVOID Append (size_t cGrow)
 
void Remove (size_t iItem, size_t cRemove=1)
 

Protected Attributes

LPBYTE m_pb
 
size_t m_cItems
 
size_t m_cbItem
 
size_t m_cCapacity
 

Detailed Description

Definition at line 12 of file cicarray.h.

Constructor & Destructor Documentation

◆ CicArrayBase()

CicArrayBase::CicArrayBase ( size_t  cbItem)

Definition at line 11 of file cicarray.cpp.

12{
13 m_cbItem = cbItem;
14 m_pb = NULL;
16}
size_t m_cCapacity
Definition: cicarray.h:16
size_t m_cbItem
Definition: cicarray.h:16
size_t m_cItems
Definition: cicarray.h:16
LPBYTE m_pb
Definition: cicarray.h:15
#define NULL
Definition: types.h:112

◆ ~CicArrayBase()

CicArrayBase::~CicArrayBase ( )
virtual

Definition at line 18 of file cicarray.cpp.

19{
21}
static void cicMemFree(LPVOID ptr)
Definition: cicbase.h:27

Member Function Documentation

◆ Append()

LPVOID CicArrayBase::Append ( size_t  cGrow)

Definition at line 23 of file cicarray.cpp.

24{
25 if (!Insert(m_cItems, cGrow))
26 return NULL;
27 return &m_pb[(m_cItems - cGrow) * m_cbItem];
28}
BOOL Insert(size_t iItem, size_t cGrow)
Definition: cicarray.cpp:30

Referenced by CicArray< T_ITEM >::Append().

◆ Insert()

BOOL CicArrayBase::Insert ( size_t  iItem,
size_t  cGrow 
)

Definition at line 30 of file cicarray.cpp.

31{
32 size_t cNewCapacity = m_cItems + cGrow;
33 if (m_cCapacity < cNewCapacity)
34 {
35 if (cNewCapacity <= m_cItems + m_cItems / 2)
36 cNewCapacity = m_cItems + m_cItems / 2;
37
38 LPBYTE pbNew = (LPBYTE)cicMemReAlloc(m_pb, cNewCapacity * m_cbItem);
39 if (!pbNew)
40 return FALSE;
41
42 m_pb = pbNew;
43 m_cCapacity = cNewCapacity;
44 }
45
46 if (iItem < m_cItems)
47 {
48 MoveMemory(&m_pb[(cGrow + iItem) * m_cbItem],
49 &m_pb[iItem * m_cbItem],
50 (m_cItems - iItem) * m_cbItem);
51 }
52
53 m_cItems += cGrow;
54 return TRUE;
55}
static LPVOID cicMemReAlloc(LPVOID ptr, SIZE_T newSize)
Definition: cicbase.h:20
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char * LPBYTE
Definition: typedefs.h:53
#define MoveMemory
Definition: winbase.h:1709

Referenced by CicArray< T_ITEM >::Remove().

◆ Remove()

void CicArrayBase::Remove ( size_t  iItem,
size_t  cRemove = 1 
)

Definition at line 57 of file cicarray.cpp.

58{
59 if (iItem + cRemove < m_cItems)
60 {
61 MoveMemory(&m_pb[iItem * m_cbItem],
62 &m_pb[(iItem + cRemove) * m_cbItem],
63 (m_cItems - iItem - cRemove) * m_cbItem);
64 }
65
66 m_cItems -= cRemove;
67
68 size_t cHalfCapacity = m_cCapacity / 2;
69 if (cHalfCapacity <= m_cItems)
70 return;
71
72 LPBYTE pb = (LPBYTE)cicMemReAlloc(m_pb, cHalfCapacity * m_cbItem);
73 if (pb)
74 {
75 m_pb = pb;
76 m_cCapacity = cHalfCapacity;
77 }
78}

Member Data Documentation

◆ m_cbItem

size_t CicArrayBase::m_cbItem
protected

◆ m_cCapacity

size_t CicArrayBase::m_cCapacity
protected

◆ m_cItems

◆ m_pb


The documentation for this class was generated from the following files: