ICU-2243 rename Utilities to LXUtilities to lessen the chance of name confilcts.

X-SVN-Rev: 12250
This commit is contained in:
Eric Mader 2003-06-03 18:28:00 +00:00
parent a764a6304b
commit df3db90aff
2 changed files with 0 additions and 125 deletions

View File

@ -1,99 +0,0 @@
/*
**********************************************************************
* Copyright (C) 2002, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#include "layout/LETypes.h"
#include "Utilities.h"
U_NAMESPACE_BEGIN
//
// Finds the high bit by binary searching
// through the bits in n.
//
le_int8 Utilities::highBit(le_int32 value)
{
if (value <= 0) {
return -32;
}
le_int8 bit = 0;
if (value >= 1 << 16) {
value >>= 16;
bit += 16;
}
if (value >= 1 << 8) {
value >>= 8;
bit += 8;
}
if (value >= 1 << 4) {
value >>= 4;
bit += 4;
}
if (value >= 1 << 2) {
value >>= 2;
bit += 2;
}
if (value >= 1 << 1) {
value >>= 1;
bit += 1;
}
return bit;
}
le_int32 Utilities::search(le_int32 value, const le_int32 array[], le_int32 count)
{
le_int32 power = 1 << highBit(count);
le_int32 extra = count - power;
le_int32 probe = power;
le_int32 index = 0;
if (value >= array[extra]) {
index = extra;
}
while (probe > (1 << 0)) {
probe >>= 1;
if (value >= array[index + probe]) {
index += probe;
}
}
return index;
}
void Utilities::reverse(le_int32 array[], le_int32 length)
{
le_int32 front, back;
for (front = 0, back = length - 1; front < back; front += 1, back -= 1) {
le_int32 swap = array[front];
array[front] = array[back];
array[back] = swap;
}
}
void Utilities::reverse(float array[], le_int32 length)
{
le_int32 front, back;
for (front = 0, back = length - 1; front < back; front += 1, back -= 1) {
float swap = array[front];
array[front] = array[back];
array[back] = swap;
}
}
U_NAMESPACE_END

View File

@ -1,26 +0,0 @@
/*
**********************************************************************
* Copyright (C) 2002, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#ifndef __UTILITIES_H
#define __UTILITIES_H
#include "layout/LETypes.h"
U_NAMESPACE_BEGIN
class Utilities
{
public:
static le_int8 highBit(le_int32 value);
static le_int32 search(le_int32 value, const le_int32 array[], le_int32 count);
static void reverse(le_int32 array[], le_int32 count);
static void reverse(float array[], le_int32 count);
};
U_NAMESPACE_END
#endif