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_EXT_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_EXT_H_ |
8 #define CORE_INCLUDE_FXCRT_FX_EXT_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_EXT_H_ |
9 | 9 |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount); | 72 void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount); |
73 | 73 |
74 void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount); | 74 void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount); |
75 | 75 |
76 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount); | 76 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount); |
77 | 77 |
78 template <class baseType> | 78 template <class baseType> |
79 class CFX_SSortTemplate { | 79 class CFX_SSortTemplate { |
80 public: | 80 public: |
81 void ShellSort(baseType* pArray, int32_t iCount) { | 81 void ShellSort(baseType* pArray, int32_t iCount) { |
82 FXSYS_assert(pArray != NULL && iCount > 0); | 82 FXSYS_assert(pArray && iCount > 0); |
83 int32_t i, j, gap; | 83 int32_t i, j, gap; |
84 baseType v1, v2; | 84 baseType v1, v2; |
85 gap = iCount >> 1; | 85 gap = iCount >> 1; |
86 while (gap > 0) { | 86 while (gap > 0) { |
87 for (i = gap; i < iCount; i++) { | 87 for (i = gap; i < iCount; i++) { |
88 j = i - gap; | 88 j = i - gap; |
89 v1 = pArray[i]; | 89 v1 = pArray[i]; |
90 while (j > -1 && (v2 = pArray[j]) > v1) { | 90 while (j > -1 && (v2 = pArray[j]) > v1) { |
91 pArray[j + gap] = v2; | 91 pArray[j + gap] = v2; |
92 j -= gap; | 92 j -= gap; |
93 } | 93 } |
94 pArray[j + gap] = v1; | 94 pArray[j + gap] = v1; |
95 } | 95 } |
96 gap >>= 1; | 96 gap >>= 1; |
97 } | 97 } |
98 } | 98 } |
99 }; | 99 }; |
100 | 100 |
101 #endif // CORE_INCLUDE_FXCRT_FX_EXT_H_ | 101 #endif // CORE_INCLUDE_FXCRT_FX_EXT_H_ |
OLD | NEW |