OLD | NEW |
1 /* | 1 /* |
2 ********************************************************************** | 2 ********************************************************************** |
3 * Copyright (c) 2004-2015, International Business Machines | 3 * Copyright (c) 2004-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ********************************************************************** | 5 ********************************************************************** |
6 * Author: Alan Liu | 6 * Author: Alan Liu |
7 * Created: April 26, 2004 | 7 * Created: April 26, 2004 |
8 * Since: ICU 3.0 | 8 * Since: ICU 3.0 |
9 ********************************************************************** | 9 ********************************************************************** |
10 */ | 10 */ |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 uenum_close(uenum); | 1145 uenum_close(uenum); |
1146 return NULL; | 1146 return NULL; |
1147 } | 1147 } |
1148 return result; | 1148 return result; |
1149 } | 1149 } |
1150 | 1150 |
1151 int32_t MeasureUnit::getIndexCount() { | 1151 int32_t MeasureUnit::getIndexCount() { |
1152 return gIndexes[UPRV_LENGTHOF(gIndexes) - 1]; | 1152 return gIndexes[UPRV_LENGTHOF(gIndexes) - 1]; |
1153 } | 1153 } |
1154 | 1154 |
| 1155 int32_t MeasureUnit::internalGetIndexForTypeAndSubtype(const char *type, const c
har *subtype) { |
| 1156 int32_t t = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), type); |
| 1157 if (t < 0) { |
| 1158 return t; |
| 1159 } |
| 1160 int32_t st = binarySearch(gSubTypes, gOffsets[t], gOffsets[t + 1], subtype); |
| 1161 if (st < 0) { |
| 1162 return st; |
| 1163 } |
| 1164 return gIndexes[t] + st - gOffsets[t]; |
| 1165 } |
| 1166 |
1155 MeasureUnit *MeasureUnit::resolveUnitPerUnit( | 1167 MeasureUnit *MeasureUnit::resolveUnitPerUnit( |
1156 const MeasureUnit &unit, const MeasureUnit &perUnit) { | 1168 const MeasureUnit &unit, const MeasureUnit &perUnit) { |
1157 int32_t unitOffset = unit.getOffset(); | 1169 int32_t unitOffset = unit.getOffset(); |
1158 int32_t perUnitOffset = perUnit.getOffset(); | 1170 int32_t perUnitOffset = perUnit.getOffset(); |
1159 | 1171 |
1160 // binary search for (unitOffset, perUnitOffset) | 1172 // binary search for (unitOffset, perUnitOffset) |
1161 int32_t start = 0; | 1173 int32_t start = 0; |
1162 int32_t end = UPRV_LENGTHOF(unitPerUnitToSingleUnit); | 1174 int32_t end = UPRV_LENGTHOF(unitPerUnitToSingleUnit); |
1163 while (start < end) { | 1175 while (start < end) { |
1164 int32_t mid = (start + end) / 2; | 1176 int32_t mid = (start + end) / 2; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 fCurrency[0] = 0; | 1231 fCurrency[0] = 0; |
1220 } | 1232 } |
1221 | 1233 |
1222 int32_t MeasureUnit::getOffset() const { | 1234 int32_t MeasureUnit::getOffset() const { |
1223 return gOffsets[fTypeId] + fSubTypeId; | 1235 return gOffsets[fTypeId] + fSubTypeId; |
1224 } | 1236 } |
1225 | 1237 |
1226 U_NAMESPACE_END | 1238 U_NAMESPACE_END |
1227 | 1239 |
1228 #endif /* !UNCONFIG_NO_FORMATTING */ | 1240 #endif /* !UNCONFIG_NO_FORMATTING */ |
OLD | NEW |