Class Judy::Judy1
In: judy.rb
Parent: Object

A Judy1 array is the equivalent of a bit array or bit map. A bit is addressed by an index (or key). The array may be sparse, and the index may be any word-sized value. If an index is present, it represents a set bit (a bit set represents an index present). If an index is absent, it represents an unset bit (a bit unset represents an absent index).

Methods
by_count    count    each_empty_index    each_index    first_empty_index    first_index    free_array    full?    last_empty_index    last_index    mem_used    new    next_empty_index    next_index    prev_empty_index    prev_index    set    test    to_a    to_s    unset   
Public Class methods
new()

Construct an empty Judy1 array.

Public Instance methods
set(index)

Set index's bit in the array. Returns true if index's bit was previously unset (successful), or false if the bit was already set (unsuccessful).

unset(index)

Unset index's bit in the array; that is, remove index from the array. Returns true if index's bit was previously set (successful), or false if the bit was already unset (unsuccessful).

test(index)

Returns true if index's bit is set, otherwise false.

count(index1, index2)

The zero-argument form of count returns the total number of indices present in the array. The two-argument form of count returns the number of indices present between index1 and index2, inclusive. Returns zero if there are no indices present between index1 and index2.

by_count(n)

Locate the nth index that is present in the array (where n=1 returns the first index present). To refer to the last index in a fully populated array (i.e. all indices present, which is rare) use n=0. Returns nil if at least n indices aren't present.

free_array()

Free the entire array (and return the number of bytes freed).

mem_used()

Return the number of bytes of memory currently in use by the array. This is a very fast routine and may be used after a call to set or unset with little performance impact.

first_index(index=0)

Search (inclusive) for the first index present that is equal to or greater than index. Start with index=0 to find the first index in the array. Returns nil if no indices greater than or equal to index are found.

next_index(index)

Search (exclusive) for the next index present that is greater than index. Returns nil if no indices greater than index are found.

last_index(index=-1)

Search (inclusive) for the last index present that is equal to or less than index. Start with index=-1 to find the last index in the array. Returns nil if no indices less than or equal to index are found.

prev_index(index)

Search (exclusive) for the previous index present that is less than index. Returns nil if no indices less than to index are found.

first_empty_index(index=0)

Search (inclusive) for the first absent index that is equal to or greater than index. Start with index=0 to find the first index absent from the array. Returns nil if no empty indices greater than or equal to index are found.

next_empty_index(index)

Search (exclusive) for the next absent index that is greater than index. Returns nil if no empty indices greater than index are found.

last_empty_index(index=-1)

Search (inclusive) for the last absent index that is equal to or less than index. Start with index=-1 to find the last index absent from the array. Returns nil if no empty indices less than or equal to index are found.

prev_empty_index(index)

Search (exclusive) for the previous absent index that is less than index. Returns nil if no empty indices less than index are found.

each_index()

Calls block once for each index present in the array, passing that index as a parameter.

each_empty_index()

Calls block once for each index that is absent from the array, passing that index as a parameter.

full?()

Return true if the array is full, false otherwise.

to_a()

Convert to an array

to_s()

Convert to a string