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

A JudyL array is the equivalent of an array of word-sized values. A value is addressed by an index (key). The array may be sparse and the index may be any word-sized number. Memory to support the array is allocated as index/value pairs are inserted, and released as index/value pairs are deleted.

Methods
[]    []=    by_count    clear    count    delete_at    each    each_empty_index    each_index    empty?    first    first_empty_index    first_index    free_array    full?    include?    last    last_empty_index    last_index    mem_used    new    next_empty_index    next_index    nitems    prev_empty_index    prev_index    to_a    to_s   
Public Class methods
new()

Construct an empty JudyL array.

Public Instance methods
[]=(index, value)

Insert an index and value into the array, and return a reference to value. If index is already present, replace the old value with value.

delete_at(index)

Delete index from the array and return the value that was stored at that index (or nil if none).

[](index)

Return the value stored at index (or nil if the index is not present).

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)

Return the nth index that is present in the array (where n=1 returns the first index present), or nil if there are not at least n indices present in the array.

free_array()

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

mem_used()

Return the number of bytes of memory currently used by the array. This is a very fast routine and may be used after inserting or removing indices 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 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.

first()

Returns the first non-nil element of the array, or nil if empty.

last()

Returns the last non-nil element of the array, or nil if empty.

each()

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

each_index()

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

each_empty_index()

Calls block once for each empty element in the array, passing that element's index as a parameter.

clear()

Removes all elements from the array.

empty?()

Returns true if array contains no elements.

nitems()

Returns the number of non-empty elements.

include?(obj)

Returns true if the given object is present in the array.

full?()

Return true if the array is full, false otherwise.

to_a()

Converts this JudyL array to a Ruby Array.

to_s()

Convert to a String