« blib/lib/Perl/Structure/Array/Reference.pm
↑ Summary
blib/lib/Perl/Structure/Array/SubTypes3D.pm »
| 1 | ## no critic qw(ProhibitUselessNoCritic PodSpelling ProhibitExcessMainComplexity) # DEVELOPER DEFAULT 1a: allow unreachable & POD-commented code; SYSTEM SPECIAL 4: allow complex code outside subroutines, must be on line 1 | ||
| 2 | package Perl::Structure::Array::SubTypes2D; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use Perl::Config; # don't use Perl::Types inside itself, in order to avoid circular includes | ||
| 6 | our $VERSION = 0.018_000; | ||
| 7 | |||
| 8 | # [[[ CRITICS ]]] | ||
| 9 | ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator | ||
| 10 | ## no critic qw(ProhibitUnreachableCode RequirePodSections RequirePodAtEnd) # DEVELOPER DEFAULT 1b: allow unreachable & POD-commented code, must be after line 1 | ||
| 11 | ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils | ||
| 12 | ## no critic qw(Capitalization ProhibitMultiplePackages ProhibitReusedNames) # SYSTEM DEFAULT 3: allow multiple & lower case package names | ||
| 13 | |||
| 14 | # [[[ EXPORTS ]]] | ||
| 15 | # DEV NOTE, CORRELATION #rp051: hard-coded list of RPerl data types and data structures | ||
| 16 | use Exporter 'import'; | ||
| 17 | our @EXPORT = qw(); | ||
| 18 | our @EXPORT_OK = qw(); | ||
| 19 | |||
| 20 | # [[[ ARRAY REF ARRAY REF (2-dimensional) ]]] | ||
| 21 | # [[[ ARRAY REF ARRAY REF (2-dimensional) ]]] | ||
| 22 | # [[[ ARRAY REF ARRAY REF (2-dimensional) ]]] | ||
| 23 | |||
| 24 | # (ref to array) of (refs to arrays) | ||
| 25 | package arrayref::arrayref; | ||
| 26 | use strict; | ||
| 27 | use warnings; | ||
| 28 | use parent -norequire, qw(arrayref); | ||
| 29 | |||
| 30 | # [[[ HOMOGENEOUS ARRAY REF ARRAY REF (2-dimensional) ]]] | ||
| 31 | # [[[ HOMOGENEOUS ARRAY REF ARRAY REF (2-dimensional) ]]] | ||
| 32 | # [[[ HOMOGENEOUS ARRAY REF ARRAY REF (2-dimensional) ]]] | ||
| 33 | |||
| 34 | # (ref to array) of (refs to (arrays of integers)) | ||
| 35 | package arrayref::arrayref::integer; | ||
| 36 | use strict; | ||
| 37 | use warnings; | ||
| 38 | use parent -norequire, qw(arrayref::arrayref); | ||
| 39 | |||
| 40 | use Perl::Config; # for 'use English;' etc. | ||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | # START HERE: implement arrayref_arrayref_integer_CHECK() & arrayref_arrayref_integer_to_string() & arrayref_arrayref_integer_typetest() numbered variations as in Hash/SubTypes.pm, then arrayref_arrayref_TYPE, then arrayref_hashref_TYPE | ||
| 46 | # START HERE: implement arrayref_arrayref_integer_CHECK() & arrayref_arrayref_integer_to_string() & arrayref_arrayref_integer_typetest() numbered variations as in Hash/SubTypes.pm, then arrayref_arrayref_TYPE, then arrayref_hashref_TYPE | ||
| 47 | # START HERE: implement arrayref_arrayref_integer_CHECK() & arrayref_arrayref_integer_to_string() & arrayref_arrayref_integer_typetest() numbered variations as in Hash/SubTypes.pm, then arrayref_arrayref_TYPE, then arrayref_hashref_TYPE | ||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | # emulate C++ behavior by actually creating arrays (and presumably allocating memory) at initialization time | ||
| 53 | sub new { | ||
| 54 | { my arrayref::arrayref::integer $RETURN_TYPE }; | ||
| 55 | ( my integer $row_count, my integer $column_count ) = @ARG; # row-major form (RMF) | ||
| 56 | my arrayref::arrayref::integer $retval = []; | ||
| 57 | for my integer $j (0 .. ($row_count - 1)) { | ||
| 58 | my arrayref::integer $retval_row = []; | ||
| 59 | for my integer $i (0 .. ($column_count - 1)) { | ||
| 60 | $retval_row->[$i] = undef; | ||
| 61 | } | ||
| 62 | $retval->[$j] = $retval_row; | ||
| 63 | } | ||
| 64 | return $retval; | ||
| 65 | } | ||
| 66 | |||
| 67 | # (ref to array) of (refs to (arrays of numbers)) | ||
| 68 | package arrayref::arrayref::number; | ||
| 69 | use strict; | ||
| 70 | use warnings; | ||
| 71 | use parent -norequire, qw(arrayref::arrayref); | ||
| 72 | |||
| 73 | use Perl::Config; # for 'use English;' etc. | ||
| 74 | |||
| 75 | # emulate C++ behavior by actually creating arrays (and presumably allocating memory) at initialization time | ||
| 76 | sub new { | ||
| 77 | { my arrayref::arrayref::number $RETURN_TYPE }; | ||
| 78 | ( my integer $row_count, my integer $column_count ) = @ARG; # row-major form (RMF) | ||
| 79 | my arrayref::arrayref::number $retval = []; | ||
| 80 | for my integer $j (0 .. ($row_count - 1)) { | ||
| 81 | my arrayref::number $retval_row = []; | ||
| 82 | for my integer $i (0 .. ($column_count - 1)) { | ||
| 83 | $retval_row->[$i] = undef; | ||
| 84 | } | ||
| 85 | $retval->[$j] = $retval_row; | ||
| 86 | } | ||
| 87 | return $retval; | ||
| 88 | } | ||
| 89 | |||
| 90 | # (ref to array) of (refs to (arrays of strings)) | ||
| 91 | package arrayref::arrayref::string; | ||
| 92 | use strict; | ||
| 93 | use warnings; | ||
| 94 | use parent -norequire, qw(arrayref::arrayref); | ||
| 95 | |||
| 96 | use Perl::Config; # for 'use English;' etc. | ||
| 97 | |||
| 98 | # emulate C++ behavior by actually creating arrays (and presumably allocating memory) at initialization time | ||
| 99 | sub new { | ||
| 100 | { my arrayref::arrayref::string $RETURN_TYPE }; | ||
| 101 | ( my integer $row_count, my integer $column_count ) = @ARG; # row-major form (RMF) | ||
| 102 | my arrayref::arrayref::string $retval = []; | ||
| 103 | for my integer $j (0 .. ($row_count - 1)) { | ||
| 104 | my arrayref::string $retval_row = []; | ||
| 105 | for my integer $i (0 .. ($column_count - 1)) { | ||
| 106 | $retval_row->[$i] = undef; | ||
| 107 | } | ||
| 108 | $retval->[$j] = $retval_row; | ||
| 109 | } | ||
| 110 | return $retval; | ||
| 111 | } | ||
| 112 | |||
| 113 | # (ref to array) of (refs to (arrays of scalars)) | ||
| 114 | package arrayref::arrayref::scalartype; | ||
| 115 | use strict; | ||
| 116 | use warnings; | ||
| 117 | use parent -norequire, qw(arrayref::arrayref); | ||
| 118 | |||
| 119 | use Perl::Config; # for 'use English;' etc. | ||
| 120 | |||
| 121 | # emulate C++ behavior by actually creating arrays (and presumably allocating memory) at initialization time | ||
| 122 | sub new { | ||
| 123 | { my arrayref::arrayref::scalartype $RETURN_TYPE }; | ||
| 124 | ( my integer $row_count, my integer $column_count ) = @ARG; # row-major form (RMF) | ||
| 125 | my arrayref::arrayref::scalartype $retval = []; | ||
| 126 | for my integer $j (0 .. ($row_count - 1)) { | ||
| 127 | my arrayref::scalartype $retval_row = []; | ||
| 128 | for my integer $i (0 .. ($column_count - 1)) { | ||
| 129 | $retval_row->[$i] = undef; | ||
| 130 | } | ||
| 131 | $retval->[$j] = $retval_row; | ||
| 132 | } | ||
| 133 | return $retval; | ||
| 134 | } | ||
| 135 | |||
| 136 | # [[[ ARRAY REF HASH REF ]]] | ||
| 137 | # [[[ ARRAY REF HASH REF ]]] | ||
| 138 | # [[[ ARRAY REF HASH REF ]]] | ||
| 139 | |||
| 140 | # (ref to array) of (refs to hashs) | ||
| 141 | package arrayref::hashref; | ||
| 142 | use strict; | ||
| 143 | use warnings; | ||
| 144 | use parent -norequire, qw(arrayref); | ||
| 145 | |||
| 146 | # START HERE: implement new() constructors for arrayref::hashref::* types; add missing arrayref::hashref::boolean etc | ||
| 147 | # START HERE: implement new() constructors for arrayref::hashref::* types; add missing arrayref::hashref::boolean etc | ||
| 148 | # START HERE: implement new() constructors for arrayref::hashref::* types; add missing arrayref::hashref::boolean etc | ||
| 149 | |||
| 150 | # (ref to array) of (refs to (hashes of integers)) | ||
| 151 | package arrayref::hashref::integer; | ||
| 152 | use strict; | ||
| 153 | use warnings; | ||
| 154 | use parent -norequire, qw(arrayref::hashref); | ||
| 155 | |||
| 156 | # (ref to array) of (refs to (hashes of numbers)) | ||
| 157 | package arrayref::hashref::number; | ||
| 158 | use strict; | ||
| 159 | use warnings; | ||
| 160 | use parent -norequire, qw(arrayref::hashref); | ||
| 161 | |||
| 162 | # (ref to array) of (refs to (hashes of strings)) | ||
| 163 | package arrayref::hashref::string; | ||
| 164 | use strict; | ||
| 165 | use warnings; | ||
| 166 | use parent -norequire, qw(arrayref::hashref); | ||
| 167 | |||
| 168 | # NEED ANSWER: are object arrays really 2-D, or are they 1-D??? | ||
| 169 | |||
| 170 | # [[[ ARRAY REF OBJECT ]]] | ||
| 171 | # [[[ ARRAY REF OBJECT ]]] | ||
| 172 | # [[[ ARRAY REF OBJECT ]]] | ||
| 173 | |||
| 174 | # (ref to array) of objects | ||
| 175 | package arrayref::object; | ||
| 176 | use strict; | ||
| 177 | use warnings; | ||
| 178 | use parent -norequire, qw(arrayref); | ||
| 179 | |||
| 180 | 1; # end of package |