Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1185)

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_List.h

Issue 1319713003: Make a bunch of JBig2 classes independent of CJBig2_Object. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: more Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp ('k') | core/src/fxcodec/jbig2/JBig2_Page.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _JBIG2_LIST_H_ 7 #ifndef _JBIG2_LIST_H_
8 #define _JBIG2_LIST_H_ 8 #define _JBIG2_LIST_H_
9 #include "JBig2_Define.h" 9
10 #include "JBig2_Object.h" 10 #include <vector>
11
11 template <class TYPE> 12 template <class TYPE>
12 class CJBig2_List : public CJBig2_Object { 13 class CJBig2_List {
13 public: 14 public:
14 CJBig2_List(int32_t nSize = 8) { 15 CJBig2_List() {}
15 m_nSize = nSize;
16 m_pArray = (TYPE**)m_pModule->JBig2_Malloc2(sizeof(TYPE*), nSize);
17 m_nLength = 0;
18 }
19 16
20 ~CJBig2_List() { 17 ~CJBig2_List() {
21 clear(); 18 clear();
22 m_pModule->JBig2_Free(m_pArray);
23 } 19 }
24 20
25 void clear() { 21 void clear() {
26 int32_t i; 22 for (size_t i = 0; i < m_vector.size(); ++i)
27 for (i = 0; i < m_nLength; i++) { 23 delete m_vector[i];
28 delete m_pArray[i]; 24 m_vector.clear();
29 }
30 m_nLength = 0;
31 } 25 }
32 26
33 void addItem(TYPE* pItem) { 27 void push_back(TYPE* pItem) { m_vector.push_back(pItem); }
34 if (m_nLength >= m_nSize) {
35 m_nSize += 8;
36 m_pArray =
37 (TYPE**)m_pModule->JBig2_Realloc(m_pArray, sizeof(TYPE*) * m_nSize);
38 }
39 m_pArray[m_nLength++] = pItem;
40 }
41 28
42 int32_t getLength() { return m_nLength; } 29 size_t size() const { return m_vector.size(); }
30 void resize(size_t count) { m_vector.resize(count); }
43 31
44 TYPE* getAt(int32_t nIndex) { return m_pArray[nIndex]; } 32 TYPE* get(size_t index) { return m_vector[index]; }
45 33
46 TYPE* getLast() { return m_pArray[m_nLength - 1]; } 34 TYPE* back() { return m_vector.back(); }
47 35
48 private: 36 private:
49 int32_t m_nSize; 37 std::vector<TYPE*> m_vector;
50 TYPE** m_pArray;
51 int32_t m_nLength;
52 }; 38 };
39
53 #endif 40 #endif
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp ('k') | core/src/fxcodec/jbig2/JBig2_Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698