GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TREE::BINARY::DICTIONARY (3)

.ds Aq ’

NAME

Tree::Binary::Dictionary - A dictionary API to a binary tree

CONTENTS

DESCRIPTION

A simple class to provide a dictionary style API to a binary tree of data.

This can provide a useful alternative to a long-lived hash in long running daemons and processes.

SYNOPSIS

use Tree::Binary::Dictionary;

my $dictionary = Tree::Binary::Dictionary->new;

# populate $dictionary->add(aaaa => One); $dictionary->add(cccc => Three); $dictionary->add(dddd => Four); $dictionary->add(eeee => Five); $dictionary->add(foo => Foo); $dictionary->add(bar => quuz);

# interact $dictionary->exists(’bar’); $dictionary->get(’eeee’); $dictionary->delete(’cccc’);

# hash stuff my %hash = $dictionary->to_hash; my @values = $dictionary->values; my @keys = $dictionary->keys;

# for long running processes $dictionary->rebuild();

METHODS

    new - constructor

my $dictionary = Tree::Binary::Dictionary->new (cache => 0);

Instantiates and returns a new dictionary object.

Optional arguments are cache, which will re-use internal objects and structures rather than rebuilding them as required. Default is 1 / True.

    rebuild

$dictionary->rebuild();

Rebuilds the internal binary tree to reduce wasteful memory use

    add

my $added = $dictionary->add(bar => quuz);

Adds new key and value in dictionary object, returns true on success, warns and returns 0 on duplicate key or other failure.

    set

my $set = $dictionary->set(bar => ’quuuz’);

Sets key and value in dictionary object, returns true on success, 0 on error.

This will add a new key and value if the key is new, or update the value of an existing key

    exists

$dictionary->exists(’bar’);

    get

my $value = $dictionary->get(’eeee’);

    delete

my $deleted = $dictionary->delete(’cccc’);

    to_hash

my %hash = $dictionary->to_hash;

returns a hash populated from the dictionary

    values

my @values = $dictionary->values;

returns dictionary values as an array

    keys

my @keys = $dictionary->keys;

returns dictionary keys as an array

    count

my $count = $dictionary->count

returns the number of entries in the dictionary

SEE ALSO

Tree::Binary

AUTHOR

aaron trevena, <teejay@droogs.org>

COPYRIGHT AND LICENSE

Copyright (C) 2006 by Aaron Trevena

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TREE::BINARY::DICTIONARY (3) 2006-07-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.