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
Tree::Binary::Dictionary(3) User Contributed Perl Documentation Tree::Binary::Dictionary(3)

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

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.

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();

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.

$dictionary->rebuild();

Rebuilds the internal binary tree to reduce wasteful memory use

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.

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

$dictionary->exists('bar');

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

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

my %hash = $dictionary->to_hash;

returns a hash populated from the dictionary

my @values = $dictionary->values;

returns dictionary values as an array

my @keys = $dictionary->keys;

returns dictionary keys as an array

my $count = $dictionary->count

returns the number of entries in the dictionary

Tree::Binary

aaron trevena, <teejay@droogs.org>

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.

2006-07-17 perl v5.32.1

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

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