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 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 "fx_memory.h" | 10 #include "fx_memory.h" |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 750 |
751 void EstimateSize(FX_DWORD size, FX_DWORD grow_by); | 751 void EstimateSize(FX_DWORD size, FX_DWORD grow_by); |
752 | 752 |
753 FX_POSITION GetStartPosition() const; | 753 FX_POSITION GetStartPosition() const; |
754 | 754 |
755 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const; | 755 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX_DWORD& value) const; |
756 | 756 |
757 protected: | 757 protected: |
758 CFX_BinaryBuf m_Buffer; | 758 CFX_BinaryBuf m_Buffer; |
759 }; | 759 }; |
760 class CFX_MapByteStringToPtr { | |
761 protected: | |
762 struct CAssoc { | |
763 CAssoc* pNext; | |
764 | |
765 FX_DWORD nHashValue; | |
766 | |
767 CFX_ByteString key; | |
768 | |
769 void* value; | |
770 }; | |
771 | |
772 public: | |
773 CFX_MapByteStringToPtr(int nBlockSize = 10); | |
774 | |
775 int GetCount() const { return m_nCount; } | |
776 | |
777 FX_BOOL IsEmpty() const { return m_nCount == 0; } | |
778 | |
779 FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const; | |
780 | |
781 void*& operator[](const CFX_ByteStringC& key); | |
782 | |
783 void SetAt(const CFX_ByteStringC& key, void* newValue) { | |
784 (*this)[key] = newValue; | |
785 } | |
786 | |
787 FX_BOOL RemoveKey(const CFX_ByteStringC& key); | |
788 | |
789 void RemoveAll(); | |
790 | |
791 FX_POSITION GetStartPosition() const { | |
792 return (m_nCount == 0) ? NULL : (FX_POSITION)-1; | |
793 } | |
794 | |
795 void GetNextAssoc(FX_POSITION& rNextPosition, | |
796 CFX_ByteString& rKey, | |
797 void*& rValue) const; | |
798 | |
799 void* GetNextValue(FX_POSITION& rNextPosition) const; | |
800 | |
801 FX_DWORD GetHashTableSize() const { return m_nHashTableSize; } | |
802 | |
803 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); | |
804 | |
805 FX_DWORD HashKey(const CFX_ByteStringC& key) const; | |
806 | |
807 protected: | |
808 CAssoc** m_pHashTable; | |
809 | |
810 FX_DWORD m_nHashTableSize; | |
811 | |
812 int m_nCount; | |
813 | |
814 CAssoc* m_pFreeList; | |
815 | |
816 struct CFX_Plex* m_pBlocks; | |
817 | |
818 int m_nBlockSize; | |
819 | |
820 CAssoc* NewAssoc(); | |
821 | |
822 void FreeAssoc(CAssoc* pAssoc); | |
823 | |
824 CAssoc* GetAssocAt(const CFX_ByteStringC& key, FX_DWORD& hash) const; | |
825 | |
826 public: | |
827 ~CFX_MapByteStringToPtr(); | |
828 }; | |
829 class CFX_CMapByteStringToPtr { | 760 class CFX_CMapByteStringToPtr { |
830 public: | 761 public: |
831 CFX_CMapByteStringToPtr(); | 762 CFX_CMapByteStringToPtr(); |
832 | 763 |
833 ~CFX_CMapByteStringToPtr(); | 764 ~CFX_CMapByteStringToPtr(); |
834 | 765 |
835 void RemoveAll(); | 766 void RemoveAll(); |
836 | 767 |
837 FX_POSITION GetStartPosition() const; | 768 FX_POSITION GetStartPosition() const; |
838 | 769 |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 FX_FLOAT c; | 1307 FX_FLOAT c; |
1377 FX_FLOAT d; | 1308 FX_FLOAT d; |
1378 FX_FLOAT e; | 1309 FX_FLOAT e; |
1379 FX_FLOAT f; | 1310 FX_FLOAT f; |
1380 FX_FLOAT g; | 1311 FX_FLOAT g; |
1381 FX_FLOAT h; | 1312 FX_FLOAT h; |
1382 FX_FLOAT i; | 1313 FX_FLOAT i; |
1383 }; | 1314 }; |
1384 | 1315 |
1385 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1316 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
OLD | NEW |