]>
git.saurik.com Git - apple/icu.git/blob - icuSources/layoutex/LXUtilities.cpp
2 **********************************************************************
3 * Copyright (C) 2002-2003, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
8 #include "layout/LETypes.h"
9 #include "LXUtilities.h"
14 // Finds the high bit by binary searching
15 // through the bits in n.
17 le_int8
LXUtilities::highBit(le_int32 value
)
25 if (value
>= 1 << 16) {
30 if (value
>= 1 << 8) {
35 if (value
>= 1 << 4) {
40 if (value
>= 1 << 2) {
45 if (value
>= 1 << 1) {
53 le_int32
LXUtilities::search(le_int32 value
, const le_int32 array
[], le_int32 count
)
55 le_int32 power
= 1 << highBit(count
);
56 le_int32 extra
= count
- power
;
57 le_int32 probe
= power
;
60 if (value
>= array
[extra
]) {
64 while (probe
> (1 << 0)) {
67 if (value
>= array
[index
+ probe
]) {
75 void LXUtilities::reverse(le_int32 array
[], le_int32 length
)
79 for (front
= 0, back
= length
- 1; front
< back
; front
+= 1, back
-= 1) {
80 le_int32 swap
= array
[front
];
82 array
[front
] = array
[back
];
87 void LXUtilities::reverse(float array
[], le_int32 length
)
91 for (front
= 0, back
= length
- 1; front
< back
; front
+= 1, back
-= 1) {
92 float swap
= array
[front
];
94 array
[front
] = array
[back
];