OLD | NEW |
---|---|
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 CORE_SRC_FXCODEC_JBIG2_JBIG2_LIST_H_ |
Tom Sepez
2015/10/07 19:20:01
nit: maybe add a comment here that this is a vecto
Lei Zhang
2015/10/08 04:52:04
Done.
| |
8 #define _JBIG2_LIST_H_ | 8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_LIST_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 template <class TYPE> | 12 template <class TYPE> |
13 class CJBig2_List { | 13 class CJBig2_List { |
14 public: | 14 public: |
15 CJBig2_List() {} | 15 CJBig2_List() {} |
16 | 16 |
17 ~CJBig2_List() { | 17 ~CJBig2_List() { |
18 clear(); | 18 clear(); |
19 } | 19 } |
20 | 20 |
21 void clear() { | 21 void clear() { |
Tom Sepez
2015/10/07 19:20:01
nit: Codesearch says this is called only from dtor
Lei Zhang
2015/10/08 04:52:04
clear() corresponds to vector::clear(). We may fin
| |
22 for (size_t i = 0; i < m_vector.size(); ++i) | 22 for (size_t i = 0; i < m_vector.size(); ++i) |
23 delete m_vector[i]; | 23 delete m_vector[i]; |
24 m_vector.clear(); | 24 m_vector.clear(); |
Tom Sepez
2015/10/07 19:20:01
nit: at which point the .clear() becomes pointless
Lei Zhang
2015/10/08 04:52:04
But it's ok as is.
| |
25 } | 25 } |
26 | 26 |
27 void push_back(TYPE* pItem) { m_vector.push_back(pItem); } | 27 void push_back(TYPE* pItem) { m_vector.push_back(pItem); } |
28 | 28 |
29 size_t size() const { return m_vector.size(); } | 29 size_t size() const { return m_vector.size(); } |
30 void resize(size_t count) { m_vector.resize(count); } | 30 void resize(size_t count) { m_vector.resize(count); } |
31 | 31 |
32 TYPE* get(size_t index) { return m_vector[index]; } | 32 TYPE* get(size_t index) const { return m_vector[index]; } |
33 | 33 |
Tom Sepez
2015/10/07 19:20:01
need a set method here so we can do more that just
Lei Zhang
2015/10/08 04:52:04
Maybe later when needed? Or do you prefer I use it
| |
34 TYPE* back() { return m_vector.back(); } | 34 TYPE* back() { return m_vector.back(); } |
35 | 35 |
36 private: | 36 private: |
37 std::vector<TYPE*> m_vector; | 37 std::vector<TYPE*> m_vector; |
38 }; | 38 }; |
39 | 39 |
40 #endif | 40 #endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_LIST_H_ |
OLD | NEW |