| Meta documentation | view source | Contained in the Meta distribution. |
Meta::Ds::Map - a 1-1 map object.
Copyright (C) 2001, 2002 Mark Veltzer; All rights reserved.
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.
MANIFEST: Map.pm PROJECT: meta VERSION: 0.02
package foo; use Meta::Ds::Map qw(); my($object)=Meta::Ds::Map->new(); my($result)=$object->method();
This data structure is a 1-1 map. This means that you can for instance, store a social id to driver id mapping (since no two people have the same social id or driver id). Trying to insert a value which already exists (in either of the hashes) will cause an exception.
This class is implemented using a pair of Hash structures. This means that querying in each direction (A to B or B to A) is quite efficient.
Removal is also quite efficient (O(1) on both sides).
Size is implemented as size of one of the hashes (they are always the same size).
BEGIN() new($) insert($$$) has_a($$) has_b($$) get_a($$) get_b($$) remove_a($$) remove_b($$) remove($$$) size($) clear($) foreach($$) TEST($)
Bootstrap method for this class which creates the accessors for hash_a and hash_b. This means that you can access the actual hashes using get_hash_a and get_hash_b. Just be careful to do it for read only access becuase toying with these without knowing what you are doing may render this class unusable.
This is a constructor for the Meta::Ds::Map object.
This inserts an pair into the map object.
Returns whether the map has the element in side A.
Returns whether the map has the element in side B.
This retrieves the pair of element on side A.
This retrieves the pair of element on side B.
This removes a pair according to element on side A.
This removes a pair according to element on side B.
This method removes a pair from the map.
This method will give you the size of the map.
This method will clear the map. It is quick.
This method will run a piece of code given to it on every pair of elements in the map. The code should be a subroutine which accepts two arguments. The arguments are a and then b.
This is a testing suite for the Meta::Ds::Map module. This test is should be run by a higher level management system at integration or release time or just as a regular routine to check that all is well.
Currently this test creates the object, does some manipulation and dumps it.
None.
None.
Name: Mark Veltzer Email: mailto:veltzer@cpan.org WWW: http://www.veltzer.org CPAN id: VELTZER
0.00 MV teachers project 0.01 MV more pdmt stuff 0.02 MV md5 issues
Meta::Class::MethodMaker(3), Meta::Ds::Hash(3), Meta::Error::Simple(3), Meta::Utils::Output(3), strict(3)
-stop using ordered hashes for this class - it does not make use of them.
-idea: store another hash with all pairs joined by $;. This could be used for fast iteration on all elements.
| Meta documentation | view source | Contained in the Meta distribution. |