| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef XFA_FGAS_CRT_FGAS_ALGORITHM_H_ | |
| 8 #define XFA_FGAS_CRT_FGAS_ALGORITHM_H_ | |
| 9 | |
| 10 #include <cstdint> | |
| 11 | |
| 12 #include "core/fxcrt/include/fx_basic.h" | |
| 13 | |
| 14 template <class baseType> | |
| 15 class CFX_DSPATemplate { | |
| 16 public: | |
| 17 int32_t Lookup(const baseType& find, const baseType* pArray, int32_t iCount) { | |
| 18 ASSERT(pArray); | |
| 19 if (iCount < 1) | |
| 20 return -1; | |
| 21 | |
| 22 int32_t iStart = 0, iEnd = iCount - 1, iMid; | |
| 23 do { | |
| 24 iMid = (iStart + iEnd) / 2; | |
| 25 const baseType& v = pArray[iMid]; | |
| 26 if (find == v) | |
| 27 return iMid; | |
| 28 if (find < v) | |
| 29 iEnd = iMid - 1; | |
| 30 else | |
| 31 iStart = iMid + 1; | |
| 32 } while (iStart <= iEnd); | |
| 33 return -1; | |
| 34 } | |
| 35 }; | |
| 36 | |
| 37 #endif // XFA_FGAS_CRT_FGAS_ALGORITHM_H_ | |
| OLD | NEW |