|
|||||||
module Judy
# 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).
class Judy1
# Construct an empty Judy1 array.
def initialize; end
# 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).
def set(index); end
# 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).
def unset(index); end
# Returns +true+ if _index_'s bit is set, otherwise +false+.
def test(index); end
# 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 <em>index1</em> and <em>index2</em>, inclusive.
# Returns zero if there are no indices present between <em>index1</em>
# and <em>index2</em>.
def count(index1, index2); end
# Locate the <em>n</em>th 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.
def by_count(n); end
# Free the entire array (and return the number of bytes freed).
def free_array; end
# 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.
def mem_used; end
# 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.
def first_index(index=0); end
# Search (exclusive) for the next index present that is greater than
# _index_. Returns +nil+ if no indices greater than _index_ are found.
def next_index(index); end
# 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.
def last_index(index=-1); end
# Search (exclusive) for the previous index present that is less than
# _index_.
# Returns +nil+ if no indices less than to _index_ are found.
def prev_index(index); end
# 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.
def first_empty_index(index=0); end
# Search (exclusive) for the next absent index that is greater than _index_.
# Returns +nil+ if no empty indices greater than _index_ are found.
def next_empty_index(index); end
# 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.
def last_empty_index(index=-1); end
# Search (exclusive) for the previous absent index that is less than _index_.
# Returns +nil+ if no empty indices less than _index_ are found.
def prev_empty_index(index); end
# Calls block once for each index present in the array, passing that
# index as a parameter.
def each_index; end
# Calls block once for each index that is absent from the array,
# passing that index as a parameter.
def each_empty_index; end
# Return +true+ if the array is full, +false+ otherwise.
def full? ; end
# Convert to an array
def to_a; end
# Convert to a string
def to_s; end
end
# 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.
class JudyL
# Construct an empty JudyL array.
def initialize; end
# 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_.
def []=(index, value); end
# Delete _index_ from the array and return the value that was stored
# at that index (or +nil+ if none).
def delete_at(index); end
# Return the value stored at _index_ (or +nil+ if the index
# is not present).
def [](index); end
# 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 <em>index1</em> and <em>index2</em>, inclusive.
# Returns zero if there are no indices present between <em>index1</em>
# and <em>index2</em>.
def count(index1, index2); end
# Return the <em>n</em>th 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.
def by_count(n); end
# Free the entire array and return the number of bytes freed.
def free_array; end
# 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.
def mem_used; end
# 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.
def first_index(index=0); end
# Search (exclusive) for the next index present that is greater than
# _index_.
# Returns +nil+ if no indices greater than _index_ are found.
def next_index(index); end
# 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.
def last_index(index=-1); end
# Search (exclusive) for the previous index present that is less than
# _index_.
# Returns +nil+ if no indices less than _index_ are found.
def prev_index(index); end
# 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.
def first_empty_index(index=0); end
# Search (exclusive) for the next absent index that is greater than _index_.
# Returns +nil+ if no empty indices greater than _index_ are found.
def next_empty_index(index); end
# 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.
def last_empty_index(index=-1); end
# Search (exclusive) for the previous absent index that is less than _index_.
# Returns +nil+ if no empty indices less than _index_ are found.
def prev_empty_index(index); end
# Returns the first non-+nil+ element of the array, or +nil+ if empty.
def first; end
# Returns the last non-+nil+ element of the array, or +nil+ if empty.
def last; end
# Calls block once for each element in the array, passing that
# element as a parameter.
def each; end
# Calls block once for each element in the array, passing that
# element's index as a parameter.
def each_index; end
# Calls block once for each empty element in the array, passing that
# element's index as a parameter.
def each_empty_index; end
# Removes all elements from the array.
def clear; end
# Returns +true+ if array contains no elements.
def empty? ; end
# Returns the number of non-empty elements.
def nitems; end
# Returns +true+ if the given object is present in the array.
def include?(obj); end
# Return +true+ if the array is full, +false+ otherwise.
def full? ; end
# Converts this JudyL array to an array.
def to_a; end
# Convert to a string
def to_s; end
end
# 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).
class JudySL
# Construct an empty JudySL array.
def initialize; end
# Insert a string _key_ and _value_ into the array. If _key_ is already
# present, replace the old value with _value_.
def []=(key, value); end
# Delete _key_ from the array and return the value previously stored
# for that key (or +nil+ if this key is not present).
def delete(key); end
# Return the value stored for _key_ (or +nil+.if the key
# is not present.
def [](key); end
# Free the entire array and return the number of bytes freed.
def free_array; end
# 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.
def first_key(key=""); end
# Search (exclusive) for the next key present that is greater than
# _key_.
# Return +nil+ if no keys greater than _key_ are found.
def next_key(key); end
# 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.
def last_key(key=nil); end
# Search (exclusive) for the previous key present that is less than
# _key_.
# Return +nil+ if no keys less than _key_ are found.
def prev_key(key); end
# Return +true+ if the given _key_ is present, otherwise +false+.
def has_key?(key); end
# Call block once for each key present, passing the key
# and value as parameters. Returns a reference to the array.
def each; end
# Call block once for each key present, passing the key
# as parameter. Returns a reference to the array.
def each_key; end
# Alias for JudySL#each.
def each_pair; end
# Call block once for each key, passing the value as parameter.
# Returns a reference to the array.
def each_value; end
# Remove all key-value pairs from the array and return a reference
# to the array.
def clear; end
# Return +true+ if array contains no keys, otherwise +false+.
def empty? ; end
# Returns a new array populated with the keys from this JudySL array.
# See also JudySL#values.
def keys; end
# Returns a new array populated with the values from this JudySL array.
# See also JudySL#keys.
def values; end
# Return the number of key-value pairs in the array.
def length; end
# Alias for JudySL#length.
def size; end
# Converts this JudySL array to a nested array of [_key_, _value_] arrays.
def to_a; end
# 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.
def to_s; end
end
# A JudyHash is intended as a drop-in replacement for Ruby's Hash; that is,
# the keys can be of any type (not only integers or strings) and it still
# uses the keys' _hash_ method to compute a hash code. This is an implementation
# of the ideas set out in the Judy application note "Scalable Hashing".
class JudyHash
# Construct an empty hash
def initialize; end
# Insert a _key_ and _value_ into the array. If _key_ is already
# present, replace the old value with _value_.
def []=(key, value); end
# Delete _key_ from the array and return the value previously stored
# for that key (or +nil+ if this key is not present).
def delete(key); end
# Return the value stored for _key_ (or +nil+.if the key
# is not present.
def [](key); end
# Free the entire array and return the number of bytes freed.
def free_array; end
# Return +true+ if the given _key_ is present, otherwise +false+.
def has_key?(key); end
# Call block once for each key present, passing the key
# and value as parameters. Returns a reference to the array.
def each; end
# Call block once for each key present, passing the key
# as parameter. Returns a reference to the array.
def each_key; end
# Alias for JudyHash#each.
def each_pair; end
# Call block once for each key, passing the value as parameter.
# Returns a reference to the array.
def each_value; end
# Remove all key-value pairs from the array and return a reference
# to the array.
def clear; end
# Return +true+ if array contains no keys, otherwise +false+.
def empty? ; end
# Return a new array populated with the keys from this hash.
# See also JudyHash#values.
def keys; end
# Return a new array populated with the values from this hash.
# See also JudyHash#keys.
def values; end
# Return the number of key-value pairs in the array.
def length; end
# Alias for JudyHash#length.
def size; end
# Convert this hash to a nested array of [_key_, _value_] arrays.
def to_a; end
# Convert this hash 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.
def to_s; end
end
end