08 Jan 2010 20:09:48 UTC
- Distribution: AI-ExpertSystem-Advanced
- Module version: 0.03
- Source (raw)
- Browse (raw)
- How to Contribute
- Clone repository
- Testers (50 / 0 / 0)
- KwaliteeBus factor: 0
- % Coverage
- License: perl_5
- Activity24 month
- Download (32.39KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionPFISCHER Pablo Fischerand 1 contributors
- Pablo Fischer (firstname.lastname@example.org).
AI::ExpertSystem::Advanced::Dictionary - Array/hash dictionary
The dictionary offers a unified interface for:
Reading through a list of items with a minimal use of memory since it offers an iterator that works with a stack. So everytime it gets asked for the next element it drops the first or last element of the stack.
Finding an element in the stack.
Adding or removing elements from the stack.
An array with all the keys of
stack_hash. Useful for creating the
iterable_arrayand for knowing the order of the items as they get added or removed.
The original hash, has all the elements with all their properties (eg extra keys). The disadvantage of it is that it doesn't keeps the order of the elements, hence the need of
Used by the
iterate_reverse()methods. It starts as a copy of
stackand as the iterate methods start running this array starts getting reduced until it gets to an empty list.
Looks for a given value (
$look_for). By default it will look for the value by reading the
idof each item, however this can be changed by passing a different hash key (
In case there's no match
The AI::ExpertSystem::Advanced::Dictionary consists of a hash of elements, each element has its own properties (eg, extra keys).
This method looks for the value of the given
$keyof a given element
It will return the value, but if element doesn't have the given
undefwill be returned.
Adds a new element to the
stack. The element gets added to the end of
$idparameter specifies the id of the new element and the next parameter is a stack of extra keys.
append(), but the element gets added to the top of the
Updates the extra keys of the element that matches the given
Please note that it will only update or add new keys. So if the given element already has a key and this is not provided in
%extra_keysthen it wont be modified.
Removes the element that matches the given
Returns true if the removal is successful, otherwise false is returned.
Returns the size of
Returns the first element of the
iterable_arrayis reduced by one.
If no more items are found in
iterate(), but instead of returning the first element, it returns the last element of
iterable_arraygets populated when a dictionary instance is created, however if new items are added or removed then it's extremely needed to call this method so
iterable_arraygets populated again.
Pablo Fischer (email@example.com).
Copyright (C) 2010 by Pablo Fischer.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install AI::ExpertSystem::Advanced, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install AI::ExpertSystem::Advanced
For more information on module installation, please visit the detailed CPAN module installation guide.