NAME

Meta::Ds::Hash - data structure that represents a hash table.

COPYRIGHT

Copyright (C) 2001, 2002 Mark Veltzer; All rights reserved.

LICENSE

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.

DETAILS

MANIFEST: Hash.pm
PROJECT: meta
VERSION: 0.40

SYNOPSIS

package foo;
use Meta::Ds::Hash qw();
my($hash)=Meta::Ds::Hash->new();
$hash->insert("mark","veltzer");
$hash->insert("linus","torvals");
$hash->remove("mark");
if($hash->has("mark")) {
	Meta::Utils::System::die("error");
}

DESCRIPTION

This is a library to let you create a hash like data structure. "Why should I have such a data strcuture ?" you rightly ask... Perl already supports hashes as built in structures, but these dont have a size method (for one...)... This encapsulates hash as a object and is much better (built over the builtin implementation). This is a value less hash (no values for the inserted ones...), so it effectivly acts as a set.

FUNCTIONS

new($)
insert($$$)
put($$$)
overwrite($$$)
remove($$)
size($)
has($$)
hasnt($$)
check_elem($$)
get($$)
print($$)
read($$)
write($$)
clear($)
TEST($)

FUNCTION DOCUMENTATION

new($)

Gives you a new Hash object.

insert($$$)

Inserts an element into the hash. If the element already exists this DOES NOTHING. This receives: 0. Hash object. 1. Element to insert. 2. Value to insert. This returns whether the value was actually inserted.

put($$$)

This will put a new element in the hash. If the element is already a part of the hash it will throw an exception. Arguments: 0. Hash object. 1. Element to insert. 2. Value to insert.

overwrite($$$)

This will overwrite an element in the hash. If the element is not already in the hash it will throw an exception. Arguments: 0. Hash object. 1. Element to insert. 2. Value to insert.

remove($$)

Remove an element from the hash. This receives: 0. Hash object. 1. Element to remove. This returns whether the value was actually removed.

size($)

Return the number of elements in the hash. This receives: 0. Hash object.

has($$)

Returns a boolean value according to whether the specified element is in the hash. This receives: 0. Hash object. 1. Element to check for.

hasnt($$)

Returns a boolean value according to whether the specified element is not in the hash. This receives: 0. Hash object. 1. Element to check for.

check_elem($$)

This method will verify that a certain element is indeed a member of the hash. If it is not - the method will raise an exception.

get($$)

This returns a certain element from the hash.

print($$)

This will print the hash while running the print routine on each of the sub elemes.

read($$)

This will read a hash from a file assuming that file has an entry for the hash as two string separated by a space on each line until the end of the file.

write($$)

This will write a hash table as in the read method. See that methods documentation for details.

clear($)

This method will clear all elements in the hash. It is fast.

TEST($)

Test suite for this module.

SUPER CLASSES

None.

BUGS

None.

AUTHOR

Name: Mark Veltzer
Email: mailto:veltzer@cpan.org
WWW: http://www.veltzer.org
CPAN id: VELTZER

HISTORY

0.00 MV initial code brought in
0.01 MV bring databases on line
0.02 MV handle architectures better
0.03 MV get the databases to work
0.04 MV ok. This is for real
0.05 MV ok - this time I realy mean it
0.06 MV make quality checks on perl code
0.07 MV more perl checks
0.08 MV make Meta::Utils::Opts object oriented
0.09 MV check that all uses have qw
0.10 MV fix todo items look in pod documentation
0.11 MV add enumerated types to options
0.12 MV more on tests/more checks to perl
0.13 MV change new methods to have prototypes
0.14 MV correct die usage
0.15 MV finish Simul documentation
0.16 MV perl code quality
0.17 MV more perl quality
0.18 MV more perl quality
0.19 MV perl documentation
0.20 MV more perl quality
0.21 MV perl qulity code
0.22 MV more perl code quality
0.23 MV revision change
0.24 MV languages.pl test online
0.25 MV PDMT/SWIG support
0.26 MV Pdmt stuff
0.27 MV perl packaging
0.28 MV md5 project
0.29 MV database
0.30 MV perl module versions in files
0.31 MV movies and small fixes
0.32 MV more thumbnail stuff
0.33 MV thumbnail user interface
0.34 MV more thumbnail issues
0.35 MV website construction
0.36 MV web site automation
0.37 MV SEE ALSO section fix
0.38 MV move tests to modules
0.39 MV weblog issues
0.40 MV teachers project

SEE ALSO

Meta::Utils::System(3), strict(3)

TODO

-Add many more routines: 1. add/subtract a hash. 2. get a list from a hash. 3. get a set from a hash. 4. get a hash from a list. 5. get a hash from a set. 6. insert an element and make sure that he wasnt there. 7. remove an element and make sure that he was there.

-add a limitation on the types of objects going into the hash (they must be inheritors from some kind of object).

-make option for hash to be strict (that insert twice will yell).

-make all methods here return the hash object so more ops could be performed.