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

A JudySL array is the equivalent of a sorted set of strings, each associated with a value. A value is addressed by a string index (or key).

Methods
[]    []=    clear    delete    each    each_key    each_pair    each_value    empty?    first_key    free_array    has_key?    keys    last_key    length    new    next_key    prev_key    size    to_a    to_s    values   
Public Class methods
new()

Construct an empty JudySL array.

Public Instance methods
[]=(key, value)

Insert a string key and value into the array. If key is already present, replace the old value with value.

delete(key)

Delete key from the array and return the value previously stored for that key (or nil if this key is not present).

[](key)

Return the value stored for key (or nil.if the key is not present.

free_array()

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

first_key(key="")

Search (inclusive) for the first key present that is equal to or greater than key. Start with key="" to find the first key in the array. Return nil if no keys greater than or equal to key are found.

next_key(key)

Search (exclusive) for the next key present that is greater than key. Return nil if no keys greater than key are found.

last_key(key=nil)

Search (inclusive) for the last key present that is equal to or less than key. There is also a zero-argument form of last_key which returns the last key in the array. Return nil if no keys less than or equal to key are found.

prev_key(key)

Search (exclusive) for the previous key present that is less than key. Return nil if no keys less than key are found.

has_key?(key)

Return true if the given key is present, otherwise false.

each()

Call block once for each key present, passing the key and value as parameters. Returns a reference to the array.

each_key()

Call block once for each key present, passing the key as parameter. Returns a reference to the array.

each_pair()

Alias for JudySL#each.

each_value()

Call block once for each key, passing the value as parameter. Returns a reference to the array.

clear()

Remove all key-value pairs from the array and return a reference to the array.

empty?()

Return true if array contains no keys, otherwise false.

keys()

Returns a new array populated with the keys from this JudySL array. See also values.

values()

Returns a new array populated with the values from this JudySL array. See also keys.

length()

Return the number of key-value pairs in the array.

size()

Alias for length.

to_a()

Converts this JudySL array to a nested Ruby Array of [key, value] arrays.

to_s()

Converts this JudySL array to a String by converting it to an Array of [key, value] pairs and then converting that array to a string using Array#join with the default separator.