Chromium Code Reviews| 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 XFA_FGAS_CRT_FGAS_ALGORITHM_H_ | 7 #ifndef XFA_FGAS_CRT_FGAS_ALGORITHM_H_ |
| 8 #define XFA_FGAS_CRT_FGAS_ALGORITHM_H_ | 8 #define XFA_FGAS_CRT_FGAS_ALGORITHM_H_ |
| 9 | 9 |
| 10 #include <cstdint> | 10 #include <cstdint> |
| 11 | 11 |
| 12 #include "core/fxcrt/include/fx_basic.h" | 12 #include "core/fxcrt/include/fx_basic.h" |
| 13 | 13 |
| 14 #ifdef __cplusplus | |
| 15 extern "C" { | |
| 16 #endif | |
| 17 | |
| 18 int32_t FX_Base64EncodeA(const uint8_t* pSrc, int32_t iSrcLen, FX_CHAR* pDst); | |
| 19 int32_t FX_Base64DecodeA(const FX_CHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); | |
| 20 int32_t FX_Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst); | |
| 21 uint8_t FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow); | |
| 22 int32_t FX_SeparateStringW(const FX_WCHAR* pStr, | |
| 23 int32_t iStrLen, | |
| 24 FX_WCHAR delimiter, | |
| 25 CFX_WideStringArray& pieces); | |
| 26 #ifdef __cplusplus | |
| 27 }; | |
| 28 #endif | |
| 29 | |
| 30 template <class baseType> | 14 template <class baseType> |
| 31 class CFX_DSPATemplate { | 15 class CFX_DSPATemplate { |
|
Tom Sepez
2016/05/18 22:01:21
this needs to go someday.
dsinclair
2016/05/19 14:24:44
Acknowledged.
| |
| 32 public: | 16 public: |
| 33 int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { | 17 int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { |
| 34 ASSERT(pArray != NULL); | 18 ASSERT(pArray); |
| 35 if (iCount < 1) { | 19 if (iCount < 1) |
| 36 return -1; | 20 return -1; |
| 37 } | 21 |
| 38 int32_t iStart = 0, iEnd = iCount - 1, iMid; | 22 int32_t iStart = 0, iEnd = iCount - 1, iMid; |
| 39 do { | 23 do { |
| 40 iMid = (iStart + iEnd) / 2; | 24 iMid = (iStart + iEnd) / 2; |
| 41 const baseType& v = pArray[iMid]; | 25 const baseType& v = pArray[iMid]; |
| 42 if (find == v) { | 26 if (find == v) |
| 43 return iMid; | 27 return iMid; |
| 44 } else if (find < v) { | 28 if (find < v) |
| 45 iEnd = iMid - 1; | 29 iEnd = iMid - 1; |
| 46 } else { | 30 else |
| 47 iStart = iMid + 1; | 31 iStart = iMid + 1; |
| 48 } | |
| 49 } while (iStart <= iEnd); | 32 } while (iStart <= iEnd); |
| 50 return -1; | 33 return -1; |
| 51 } | 34 } |
| 52 }; | 35 }; |
| 53 | 36 |
| 54 #endif // XFA_FGAS_CRT_FGAS_ALGORITHM_H_ | 37 #endif // XFA_FGAS_CRT_FGAS_ALGORITHM_H_ |
| OLD | NEW |