summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/jbig2/JBig2_List.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-09-03 16:03:42 -0700
committerLei Zhang <thestig@chromium.org>2015-09-03 16:03:42 -0700
commit800bf5ac07305ccf9c9522c8c76f728a4fd99da5 (patch)
tree9adfb205c88e1e074e955d7731850d36594011e1 /core/src/fxcodec/jbig2/JBig2_List.h
parent640c395fa9b76552383ccd0c5f4668ea698089f6 (diff)
downloadpdfium-800bf5ac07305ccf9c9522c8c76f728a4fd99da5.tar.xz
Make a bunch of JBig2 classes independent of CJBig2_Object.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1319713003 .
Diffstat (limited to 'core/src/fxcodec/jbig2/JBig2_List.h')
-rw-r--r--core/src/fxcodec/jbig2/JBig2_List.h43
1 files changed, 15 insertions, 28 deletions
diff --git a/core/src/fxcodec/jbig2/JBig2_List.h b/core/src/fxcodec/jbig2/JBig2_List.h
index be2d7cb7e4..e033eb23ea 100644
--- a/core/src/fxcodec/jbig2/JBig2_List.h
+++ b/core/src/fxcodec/jbig2/JBig2_List.h
@@ -6,48 +6,35 @@
#ifndef _JBIG2_LIST_H_
#define _JBIG2_LIST_H_
-#include "JBig2_Define.h"
-#include "JBig2_Object.h"
+
+#include <vector>
+
template <class TYPE>
-class CJBig2_List : public CJBig2_Object {
+class CJBig2_List {
public:
- CJBig2_List(int32_t nSize = 8) {
- m_nSize = nSize;
- m_pArray = (TYPE**)m_pModule->JBig2_Malloc2(sizeof(TYPE*), nSize);
- m_nLength = 0;
- }
+ CJBig2_List() {}
~CJBig2_List() {
clear();
- m_pModule->JBig2_Free(m_pArray);
}
void clear() {
- int32_t i;
- for (i = 0; i < m_nLength; i++) {
- delete m_pArray[i];
- }
- m_nLength = 0;
+ for (size_t i = 0; i < m_vector.size(); ++i)
+ delete m_vector[i];
+ m_vector.clear();
}
- void addItem(TYPE* pItem) {
- if (m_nLength >= m_nSize) {
- m_nSize += 8;
- m_pArray =
- (TYPE**)m_pModule->JBig2_Realloc(m_pArray, sizeof(TYPE*) * m_nSize);
- }
- m_pArray[m_nLength++] = pItem;
- }
+ void push_back(TYPE* pItem) { m_vector.push_back(pItem); }
- int32_t getLength() { return m_nLength; }
+ size_t size() const { return m_vector.size(); }
+ void resize(size_t count) { m_vector.resize(count); }
- TYPE* getAt(int32_t nIndex) { return m_pArray[nIndex]; }
+ TYPE* get(size_t index) { return m_vector[index]; }
- TYPE* getLast() { return m_pArray[m_nLength - 1]; }
+ TYPE* back() { return m_vector.back(); }
private:
- int32_t m_nSize;
- TYPE** m_pArray;
- int32_t m_nLength;
+ std::vector<TYPE*> m_vector;
};
+
#endif