| 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 _FX_ALGORITHM | 7 #ifndef _FX_ALGORITHM |
| 8 #define _FX_ALGORITHM | 8 #define _FX_ALGORITHM |
| 9 #define FX_IsOdd(a) ((a) & 1) | 9 #define FX_IsOdd(a) ((a) & 1) |
| 10 #ifdef __cplusplus | 10 #ifdef __cplusplus |
| 11 extern "C" { | 11 extern "C" { |
| 12 #endif | 12 #endif |
| 13 FX_INT32» FX_Base64EncodeA(FX_LPCBYTE pSrc, FX_INT32 iSrcLen, FX_LPSTR pDs
t); | 13 int32_t»FX_Base64EncodeA(FX_LPCBYTE pSrc, int32_t iSrcLen, FX_LPSTR pDst); |
| 14 FX_INT32» FX_Base64DecodeA(FX_LPCSTR pSrc, FX_INT32 iSrcLen, FX_LPBYTE pDs
t); | 14 int32_t»FX_Base64DecodeA(FX_LPCSTR pSrc, int32_t iSrcLen, FX_LPBYTE pDst); |
| 15 FX_INT32» FX_Base64DecodeW(FX_LPCWSTR pSrc, FX_INT32 iSrcLen, FX_LPBYTE pD
st); | 15 int32_t»FX_Base64DecodeW(FX_LPCWSTR pSrc, int32_t iSrcLen, FX_LPBYTE pDst); |
| 16 FX_BYTE»» FX_Hex2Dec(FX_BYTE hexHigh, FX_BYTE hexLow); | 16 uint8_t»» FX_Hex2Dec(uint8_t hexHigh, uint8_t hexLow); |
| 17 FX_INT32» FX_SeparateStringW(FX_LPCWSTR pStr, FX_INT32 iStrLen, FX_WCHAR d
elimiter, CFX_WideStringArray &pieces); | 17 int32_t»FX_SeparateStringW(FX_LPCWSTR pStr, int32_t iStrLen, FX_WCHAR delimiter,
CFX_WideStringArray &pieces); |
| 18 #ifdef __cplusplus | 18 #ifdef __cplusplus |
| 19 }; | 19 }; |
| 20 #endif | 20 #endif |
| 21 template<class baseType> | 21 template<class baseType> |
| 22 class CFX_DSPATemplate | 22 class CFX_DSPATemplate |
| 23 { | 23 { |
| 24 public: | 24 public: |
| 25 FX_INT32 Lookup(const baseType &find, const baseType *pArray, FX_INT32 iCoun
t) | 25 int32_t Lookup(const baseType &find, const baseType *pArray, int32_t iCount) |
| 26 { | 26 { |
| 27 FXSYS_assert(pArray != NULL); | 27 FXSYS_assert(pArray != NULL); |
| 28 if (iCount < 1) { | 28 if (iCount < 1) { |
| 29 return -1; | 29 return -1; |
| 30 } | 30 } |
| 31 FX_INT32 iStart = 0, iEnd = iCount - 1, iMid; | 31 int32_t iStart = 0, iEnd = iCount - 1, iMid; |
| 32 do { | 32 do { |
| 33 iMid = (iStart + iEnd) / 2; | 33 iMid = (iStart + iEnd) / 2; |
| 34 const baseType &v = pArray[iMid]; | 34 const baseType &v = pArray[iMid]; |
| 35 if (find == v) { | 35 if (find == v) { |
| 36 return iMid; | 36 return iMid; |
| 37 } else if (find < v) { | 37 } else if (find < v) { |
| 38 iEnd = iMid - 1; | 38 iEnd = iMid - 1; |
| 39 } else { | 39 } else { |
| 40 iStart = iMid + 1; | 40 iStart = iMid + 1; |
| 41 } | 41 } |
| 42 } while (iStart <= iEnd); | 42 } while (iStart <= iEnd); |
| 43 return -1; | 43 return -1; |
| 44 } | 44 } |
| 45 }; | 45 }; |
| 46 #endif | 46 #endif |
| OLD | NEW |