The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Meta::Ds::Set - data structure that represents a set.

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: Set.pm
        PROJECT: meta
        VERSION: 0.38

SYNOPSIS

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

DESCRIPTION

This is a library to let you create a set like data structure. The set data structure is akin to the mathematical object of a set. A set is a collection of items where duplicates are not allowed (if you insert an item which is already in the set the set does not change). The sets operations are mainly insert, remove and testing whether elements are memebers of it or not. The set here is not ordered so you CANT iterate it's elements. If you do want to iterate them use the Oset object. If you don't - use this object and same time and memory. Don't worry - if you don't know if you do or you don't - use this object for starters - if you wind up needing iteration just switch to using the Oset - they have the same interface so you will only need to change your code in the use and object construction points. The implementation is simply based on a perl hash table and does not use the capability of the hash table to store value items beside the keys in the table.

FUNCTIONS

        new($)
        clear($)
        insert($$)
        write($$)
        remove($$)
        has($$)
        hasnt($$)
        check_has($$)
        check_hasnt($$)
        read($$)
        size($)
        contained($$)
        set_add($$)
        set_remove($$)
        foreach($$)
        get_hash($)
        filter_regexp($$)
        filter($$)
        TEST($)

FUNCTION DOCUMENTATION

new($)

Gives you a new Set object.

clear($)

This will clear the set (make it the empty set).

insert($$)

Inserts a new element into the set. If the element is already in the set then this method throws an exception.

write($$)

Inserts a new element into the set. If the element is already in the set then this method does nothing.

remove($$)

Removes an element from the set.

has($$)

Returns whether the current element is a member of the set.

hasnt($$)

Returns whether the current element is not a member of the set.

check_has($$)

Check that the element received is in the set and die if it is not. This method receives: 0. The object handle. 1. The element to check for. This method does not return anything.

check_hasnt($$)

Check that the element received is in not the set and die if it is. This method receives: 0. The object handle. 1. The element to check for. This method does not return anything.

read($$)

This method reads a file into the current set object. It does not remove previously stored elements in the set. This method receives: 0. The object handle. 1. The file name to read from. This method returns nothing.

size($)

Return the size of the set. The real size (not size-1). This method receives: 0. The object handle. This method returns the size of the set object in question.

contained($$)

This method will return a boolean value according to whether the current set is contained in another one supplied.

set_add($$)

This method will add the elements of a set given to it to the current set.

set_remove($$)

This method will remove from the current set any elements found in a set given to it.

foreach($$)

This method will iterate over all elements of the set and will feed them to a user supplied function. The function should receive a single arguement and should do whatever it wants with it.

get_hash($)

This method provides access to the underlying hash. Take heed. Use this for read only purposes.

filter_regexp($$)

This method receives a regular expression and returns a set will all members of the original set which match the regular expression.

filter($$)

This method receives a piece of code which gets a single argument. The method will run this code on each element of the set and will return only elements for which the code returned a value evaluated to true.

TEST($)

Test suite for this module. Currently this just reads a set and prints it.

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 ok. This is for real
        0.03 MV make quality checks on perl code
        0.04 MV more perl checks
        0.05 MV make Meta::Utils::Opts object oriented
        0.06 MV check that all uses have qw
        0.07 MV fix todo items look in pod documentation
        0.08 MV more on tests/more checks to perl
        0.09 MV silense all tests
        0.10 MV correct die usage
        0.11 MV finish Simul documentation
        0.12 MV perl code quality
        0.13 MV more perl quality
        0.14 MV more perl quality
        0.15 MV get basic Simul up and running
        0.16 MV perl documentation
        0.17 MV more perl quality
        0.18 MV perl qulity code
        0.19 MV more perl code quality
        0.20 MV revision change
        0.21 MV languages.pl test online
        0.22 MV PDMT/SWIG support
        0.23 MV Pdmt stuff
        0.24 MV perl packaging
        0.25 MV some chess work
        0.26 MV md5 project
        0.27 MV database
        0.28 MV perl module versions in files
        0.29 MV movies and small fixes
        0.30 MV more thumbnail code
        0.31 MV thumbnail user interface
        0.32 MV more thumbnail issues
        0.33 MV website construction
        0.34 MV web site automation
        0.35 MV SEE ALSO section fix
        0.36 MV finish papers
        0.37 MV teachers project
        0.38 MV md5 issues

SEE ALSO

Meta::Error::Simple(3), Meta::IO::File(3), Meta::Utils::Output(3), strict(3)

TODO

Nothing.