| 1 | #!/usr/bin/perl -W | ||
| 2 | package AI::MicroStructure::ObjectSet; | ||
| 3 | use strict; | ||
| 4 | |||
| 5 | sub new { | ||
| 6 | my $pkg = shift; | ||
| 7 | my $self = bless {}, $pkg; | ||
| 8 | $self->insert(@_) if @_; | ||
| 9 | return $self; | ||
| 10 | } | ||
| 11 | |||
| 12 | sub members { | ||
| 13 | return values %{$_[0]}; | ||
| 14 | } | ||
| 15 | |||
| 16 | sub size { | ||
| 17 | return scalar keys %{$_[0]}; | ||
| 18 | } | ||
| 19 | |||
| 20 | sub insert { | ||
| 21 | my $self = shift; | ||
| 22 | foreach my $element (@_) { | ||
| 23 | |||
| 24 | $self->{ $element->name } = $element; | ||
| 25 | } | ||
| 26 | |||
| 27 | return 1; | ||
| 28 | } | ||
| 29 | |||
| 30 | sub retrieve { $_[0]->{$_[1]} } | ||
| 31 | sub includes { exists $_[0]->{ $_[1]->name } } | ||
| 32 | sub includes_name { exists $_[0]->{ $_[1] } } | ||
| 33 | |||
| 34 | 1; | ||
| 35 | |||
| 36 | |||
| 37 | =head1 NAME | ||
| 38 | |||
| 39 | AI::MicroStructure::ObjectSet | ||
| 40 | |||
| 41 | =head1 DESCRIPTION | ||
| 42 | |||
| 43 | Stack of ObjectContainers | ||
| 44 | |||
| 45 | =head1 SYNOPSIS | ||
| 46 | |||
| 47 | ~$ micro new world | ||
| 48 | |||
| 49 | ~$ micro structures | ||
| 50 | |||
| 51 | ~$ micro any 2 | ||
| 52 | |||
| 53 | ~$ micro drop world | ||
| 54 | |||
| 55 | ~$ micro | ||
| 56 | |||
| 57 | =head1 AUTHOR | ||
| 58 | |||
| 59 | Hagen Geissler <santex@cpan.org> | ||
| 60 | |||
| 61 | =head1 COPYRIGHT AND LICENCE | ||
| 62 | |||
| 63 | Hagen Geissler <santex@cpan.org> | ||
| 64 | |||
| 65 | =head1 SUPPORT AND DOCUMENTATION | ||
| 66 | |||
| 67 | [sample using concepts](http://quantup.com) | ||
| 68 | |||
| 69 | [PDF info on my works](https://github.com/santex) | ||
| 70 | |||
| 71 | |||
| 72 | =head1 SEE ALSO | ||
| 73 | |||
| 74 | AI-MicroStructure | ||
| 75 | |||
| 76 | =cut |