The Mozilla
Organization
Our Mission
Who We Are
Getting Involved
Community
Editorials
What's New
Development
Roadmap
Module Owners
Blue Sky
Projects
Status
Tools
Products
Source Code
Binaries
Documentation
License Terms
Bug Reports
Search
Feedback


[Contents] [Previous] [Next][Last]


Chapter 16
BitMaps

This chapter describes the bitmap type and the functions for manipulating a bitmap type.

BitMap Type

prbitmap_t

Define a BitMap type.
syntax
#include "prbit.h"

typedef unsigned long prbitmap_t;
description
Use prbitmap_t as an array to define a bitmap of more than the 32 bits implied by a single prbitmap_t instance.

BitMap Functions

The API defined for the BitMap functions is consistent across all platforms..

PR_TEST_BIT

Test a bit within an array of prbitmap_t.
Syntax
#include <prbit.h>
PRIntn PR_TEST_BIT(prbitmap_t *_map, PRInt32 _bit);
Parameter
_map
Address of the bitmap containing _bit
_bit
The number of the bit within _map to be referenced.
Returns
non-zero if _bit within _map is on, else zero.
Description
PR_TEST_BIT tests the bit at relative position _bit within bitmap _map. The macro evaluates to true if the bit is set, else it evaluates to zero.

PR_SET_BIT

Set a bit within an array of prbitmap_t.
Syntax
#include <prbit.h>
void PR_SET_BIT(prbitmap_t *_map, PRInt32 _bit);
Parameter
_map
Address of the bitmap containing _bit
_bit
The number of the bit within _map to be referenced.
Returns
void
Description
PR_SET_BIT sets bit _bit in bitmap _map to one.

PR_CLEAR_BIT

Set a bit within an array of prbitmap_t.
Syntax
#include <prbit.h>
void PR_CLEAR_BIT(prbitmap_t *_map, PRInt32 _bit);
Parameter
_map
Address of the bitmap containing _bit
_bit
The number of the bit within _map to be referenced.
Returns
void
Description
PR_CLEAR_BIT sets bit _bit in bitmap _map to zero.

PR_CeilingLog2

Ceiling of Log2 of a number.
Syntax
#include <prbit.h>
PRIntn PR_CeilingLog2(PRUint32 i);
Parameter
i
Argument to be evaluated
Returns
Ceiling of Log2 of i.
Description
PR_CeilingLog2() takes the log2 of i, converting result to the smallest integer that is greater than or equal to log2(i).

Think of it as: Ceil(Log2(i));

Example
PRIntn j = PR_CeilingLog2( 32 ); /* After execution, j == 5 */

PR_FloorLog2

Floor of Log2 of a number.
Syntax
#include <prbit.h>
PRIntn PR_FloorLog2(PRUint32 i);
Parameter
i
Argument to be evaluated
Returns
Floor of Log2 of i.
Description
PR_FloorLog2() takes the log2 of i, converting the result to the largest integer that is less than or equal to log2(i).

Think of it as: Floor(Log2(i));

PR_CEILING_LOG2

Ceiling of Log2 of a number.
Syntax
#include <prbit.h>
void PR_CEILING_LOG2(PRUint32 _log, PRUint32 i);
Parameter
_log
Result of operation
i
Argument to be evaluated.
Returns
void
Description
Same as PR_CeilingLog2(). Implemented as a macro.

PR_FLOOR_LOG2

Floor of Log2 of a number.
Syntax
#include <prbit.h>
void PR_FLOOR_LOG2(PRUint32 _log, PRUint32 i);
Parameter
_log
Result of operation
i
Argument to be evaluated.
Returns
void
Description
Same as PR_FloorLog2(). Implemented as a macro.

[Contents] [Previous] [Next][Last]
Last Updated: Tue Jul 14 10:26:12 PDT 1998
Copyright © 1998 Netscape Communications Corporation



Copyright © 1998 The Mozilla Organization.