NAME

Meta::Ds::Noset - Ordered hash data structure.

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: Noset.pm
PROJECT: meta
VERSION: 0.02

SYNOPSIS

package foo;
use Meta::Ds::Noset qw();
my($oset)=Meta::Ds::Noset->new();
$oset->insert("mark");

DESCRIPTION

This is a set object which is also ordered (meaning you can find the ordinal number of each element and also the reverse - move from an ordinal number to the element). The structure is able to hold any perl object or scalar as element. Duplicates are not allowed (this is a set after all...). The structure uses a 1-1 mapping to do its thing by mapping numbers to the elements that you put in. This means that you can iterate over all elements of the set quite easily with little performance penalty (except the hash function lookup every loop). The set also supports the remove operation by changing the ordinal of the last element to the element which is removed. This means that removing elements while traversing the ordinals is not supported. The removal is, however, O(1). All other standard operations are O(1).

The methods which just work out of the box from the parent class are: 0. clear - clears the data structure.

FUNCTIONS

insert($$)
remove($$)
has($$)
hasnt($$)
check_has($$)
check_hasnt($$)
elem($$)
add_prefix($$)
foreach($$)
clone($)
add_set($$);
remove_set($$);
filter($$);
filter_regexp($$);
filter_content($$);
TEST($)

FUNCTION DOCUMENTATION

insert($$)

This inserts a new element into the Set. If the element is already an element it is not an error.

remove($$)

This removes an element from the Set. If the element is not an element of the set it is not an error.

has($$)

This returns whether a specific element is a member of the set.

hasnt($$)

This returns whether a specific element is not a member of the set.

check_has($$)

Thie method receives: 0. An Noset object. 1. An element to check fore. This method makes sure that the element is a member of the set and dies if it is not.

check_hasnt($$)

Thie method receives: 0. An Noset object. 1. An element to check fore. This method makes sure that the element is a member of the set and dies if it is not.

elem($$)

This method receives: 0. An Noset object. 1. A location. And retrieves the element at that location.

add_prefix($$)

This method receives: 0. An Noset object. 1. A prefix. It returns a new set which has all the elements in the old with the specified prefix.

foreach($$)

This method receives: 0. An Noset object. 1. A code reference. The method will iterate through the container and call the code on each element. The code reference should receive a single argument which is the current element.

clone($)

This method receives: 0. An Noset object. This method will return a clone of the current data structure.

add_set($$)

This method receives: 0. An Noset object. 1. Another set object. The method will add all the elements in the recieved set to the current set.

remove_set($$)

This method receives: 0. An Noset object. 1. Another set object. The method will remove all the elements in the recieved set from the current set.

filter($$)

This method receives: 0. An Noset object. 1. A code reference. The method will return a new set which will have all the elements for which the code evaluated to true.

filter_regexp($$)

This method receives: 0. An Noset object. 1. A regular expression. The method will return a new set which will have all the elements which matched the regular expression.

filter_content($$)

This method receives: 0. An Noset object. 1. A regular expression. The method will return a new set which will have all the elements for which the content as files matched the regular expression.

TEST($)

Test suite for this module.

Currently creates a set and manipulates it a little.

SUPER CLASSES

Meta::Ds::Map(3)

BUGS

None.

AUTHOR

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

HISTORY

0.00 MV teachers project
0.01 MV more pdmt stuff
0.02 MV md5 issues

SEE ALSO

Meta::Ds::Map(3), Meta::Utils::File::File(3), Meta::Utils::Output(3), strict(3)

TODO

-add a sort operation.