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

Side by Side Diff: core/include/fxcrt/fx_basic.h

Issue 1618273004: Remove CFX_SegmentedArray use from master (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits. Created 4 years, 11 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 | « no previous file | core/src/fpdftext/fpdf_text_int.cpp » ('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 CORE_INCLUDE_FXCRT_FX_BASIC_H_ 7 #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_
8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ 8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 void RemoveAll() { 474 void RemoveAll() {
475 for (int i = 0; i < m_nSize; i++) { 475 for (int i = 0; i < m_nSize; i++) {
476 ((ObjectClass*)GetDataPtr(i))->~ObjectClass(); 476 ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
477 } 477 }
478 CFX_BasicArray::SetSize(0); 478 CFX_BasicArray::SetSize(0);
479 } 479 }
480 }; 480 };
481 typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; 481 typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray;
482 typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray; 482 typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
483 class CFX_BaseSegmentedArray {
484 public:
485 CFX_BaseSegmentedArray(int unit_size = 1,
486 int segment_units = 512,
487 int index_size = 8);
488
489 ~CFX_BaseSegmentedArray();
490
491 void SetUnitSize(int unit_size, int segment_units, int index_size = 8);
492
493 void* Add();
494
495 void* GetAt(int index) const;
496
497 void RemoveAll();
498
499 void Delete(int index, int count = 1);
500
501 int GetSize() const { return m_DataSize; }
502
503 int GetSegmentSize() const { return m_SegmentSize; }
504
505 int GetUnitSize() const { return m_UnitSize; }
506
507 void* Iterate(FX_BOOL (*callback)(void* param, void* pData),
508 void* param) const;
509
510 private:
511 int m_UnitSize;
512
513 short m_SegmentSize;
514
515 uint8_t m_IndexSize;
516
517 uint8_t m_IndexDepth;
518
519 int m_DataSize;
520
521 void* m_pIndex;
522 void** GetIndex(int seg_index) const;
523 void* IterateIndex(int level,
524 int& start,
525 void** pIndex,
526 FX_BOOL (*callback)(void* param, void* pData),
527 void* param) const;
528 void* IterateSegment(const uint8_t* pSegment,
529 int count,
530 FX_BOOL (*callback)(void* param, void* pData),
531 void* param) const;
532 };
533 template <class ElementType>
534 class CFX_SegmentedArray : public CFX_BaseSegmentedArray {
535 public:
536 CFX_SegmentedArray(int segment_units, int index_size = 8)
537 : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) {
538 }
539
540 void Add(ElementType data) {
541 *(ElementType*)CFX_BaseSegmentedArray::Add() = data;
542 }
543
544 ElementType& operator[](int index) {
545 return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index);
546 }
547 };
548 template <class DataType, int FixedSize> 483 template <class DataType, int FixedSize>
549 class CFX_FixedBufGrow { 484 class CFX_FixedBufGrow {
550 public: 485 public:
551 CFX_FixedBufGrow() : m_pData(NULL) {} 486 CFX_FixedBufGrow() : m_pData(NULL) {}
552 CFX_FixedBufGrow(int data_size) : m_pData(NULL) { 487 CFX_FixedBufGrow(int data_size) : m_pData(NULL) {
553 if (data_size > FixedSize) { 488 if (data_size > FixedSize) {
554 m_pData = FX_Alloc(DataType, data_size); 489 m_pData = FX_Alloc(DataType, data_size);
555 } else { 490 } else {
556 FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize); 491 FXSYS_memset(m_Data, 0, sizeof(DataType) * FixedSize);
557 } 492 }
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 FX_FLOAT c; 983 FX_FLOAT c;
1049 FX_FLOAT d; 984 FX_FLOAT d;
1050 FX_FLOAT e; 985 FX_FLOAT e;
1051 FX_FLOAT f; 986 FX_FLOAT f;
1052 FX_FLOAT g; 987 FX_FLOAT g;
1053 FX_FLOAT h; 988 FX_FLOAT h;
1054 FX_FLOAT i; 989 FX_FLOAT i;
1055 }; 990 };
1056 991
1057 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ 992 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdftext/fpdf_text_int.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698