| 1 | # Only used to define the version of the module and the core documentation. | ||
| 2 | |||
| 3 | package DataStructure; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use utf8; | ||
| 8 | use feature ':5.24'; | ||
| 9 | |||
| 10 | our $VERSION = '0.02'; | ||
| 11 | |||
| 12 | =pod | ||
| 13 | |||
| 14 | =head1 NAME | ||
| 15 | |||
| 16 | DataStructure | ||
| 17 | |||
| 18 | =head1 SYNOPSIS | ||
| 19 | |||
| 20 | Collection of useful data-structures in pure Perl. | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | This package is only here to define a common version for all the data-structure | ||
| 25 | in this distribution and to contain the core documentation. Please refer to the | ||
| 26 | documentation of the individual data-structure for more details. | ||
| 27 | |||
| 28 | =head1 DATA-STRUCTURE IMPLEMENTATIONS | ||
| 29 | |||
| 30 | These classes are actual implementations of data-structure. You should use them | ||
| 31 | to create objects but, in general, you should then only expect object of a | ||
| 32 | particular role (see below). | ||
| 33 | |||
| 34 | =over 4 | ||
| 35 | |||
| 36 | =item L<DataStructure::DoubleList> | ||
| 37 | |||
| 38 | =item L<DataStructure::LinkedList> | ||
| 39 | |||
| 40 | =back | ||
| 41 | |||
| 42 | Note that you should never directly test the | ||
| 43 | |||
| 44 | =head1 ROLES | ||
| 45 | |||
| 46 | Roles, or data-structure interfaces, are | ||
| 47 | |||
| 48 | In DataStructure, the role are only implemented using normal Perl classes | ||
| 49 | inheritence. So you can test that an object has a particular role with | ||
| 50 | C<$obj->DOES('DataStructure::RoleName')> (you should use C<DOES> and not C<isa> | ||
| 51 | as the library might use another system in the future). | ||
| 52 | |||
| 53 | =over 4 | ||
| 54 | |||
| 55 | =item DataStructure::Queue | ||
| 56 | |||
| 57 | Implemented by L<DataStructure::LinkedList> and L<DataStructure::DoubleList> | ||
| 58 | |||
| 59 | Has the following methods C<shift()>, C<push($value)>, C<values()>, C<empty()>, | ||
| 60 | C<size()>. | ||
| 61 | |||
| 62 | Nodes have the following methods: C<value()>. | ||
| 63 | |||
| 64 | Synonym: C<DataStructure::FIFO>. | ||
| 65 | |||
| 66 | =item DataStructure::Stack | ||
| 67 | |||
| 68 | Implemented by L<DataStructure::LinkedList> (with the C<reverse> option) and | ||
| 69 | L<DataStructure::DoubleList>. | ||
| 70 | |||
| 71 | Has the following methods C<first()>, C<push($value)>, C<pop()>, C<values()>, | ||
| 72 | C<empty()>, C<size()>. | ||
| 73 | |||
| 74 | Nodes have the following methods: C<value()>, C<insert_after($value)>, C<next()>. | ||
| 75 | |||
| 76 | Note that, without the C<reverse> option a L<DataStructure::LinkedList> can also | ||
| 77 | behave like a stack but you would need to use the less common C<shift> and | ||
| 78 | C<unshift> pair of methods. In that case, it will not have the C<Stack> role. | ||
| 79 | |||
| 80 | Synonym: C<DataStructure::LIFO>. | ||
| 81 | |||
| 82 | =item DataStructure::OrderedSet | ||
| 83 | |||
| 84 | Implemented by L<DataStructure::BTree> | ||
| 85 | |||
| 86 | Has the following methods C<insert($value)>, C<find($value)>, | ||
| 87 | C<delete($value | $node)>, C<values()>, C<empty()>, C<size()>. | ||
| 88 | |||
| 89 | =back | ||
| 90 | |||
| 91 | =head1 AUTHOR | ||
| 92 | |||
| 93 | Mathias Kende <mathias@cpan.org> | ||
| 94 | |||
| 95 | =head1 LICENCE | ||
| 96 | |||
| 97 | Copyright 2021 Mathias Kende | ||
| 98 | |||
| 99 | This program is distributed under the MIT (X11) License: | ||
| 100 | L<http://www.opensource.org/licenses/mit-license.php> | ||
| 101 | |||
| 102 | Permission is hereby granted, free of charge, to any person | ||
| 103 | obtaining a copy of this software and associated documentation | ||
| 104 | files (the "Software"), to deal in the Software without | ||
| 105 | restriction, including without limitation the rights to use, | ||
| 106 | copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 107 | copies of the Software, and to permit persons to whom the | ||
| 108 | Software is furnished to do so, subject to the following | ||
| 109 | conditions: | ||
| 110 | |||
| 111 | The above copyright notice and this permission notice shall be | ||
| 112 | included in all copies or substantial portions of the Software. | ||
| 113 | |||
| 114 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 115 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
| 116 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 117 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
| 118 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| 119 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 120 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| 121 | OTHER DEALINGS IN THE SOFTWARE. | ||
| 122 | |||
| 123 | =cut | ||
| 124 | |||
| 125 | 1; |