| 1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
| 2 | .\" |
| 3 | .\" Standard preamble: |
| 4 | .\" ======================================================================== |
| 5 | .de Sh \" Subsection heading |
| 6 | .br |
| 7 | .if t .Sp |
| 8 | .ne 5 |
| 9 | .PP |
| 10 | \fB\\$1\fR |
| 11 | .PP |
| 12 | .. |
| 13 | .de Sp \" Vertical space (when we can't use .PP) |
| 14 | .if t .sp .5v |
| 15 | .if n .sp |
| 16 | .. |
| 17 | .de Vb \" Begin verbatim text |
| 18 | .ft CW |
| 19 | .nf |
| 20 | .ne \\$1 |
| 21 | .. |
| 22 | .de Ve \" End verbatim text |
| 23 | .ft R |
| 24 | .fi |
| 25 | .. |
| 26 | .\" Set up some character translations and predefined strings. \*(-- will |
| 27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left |
| 28 | .\" double quote, and \*(R" will give a right double quote. | will give a |
| 29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to |
| 30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' |
| 31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. |
| 32 | .tr \(*W-|\(bv\*(Tr |
| 33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' |
| 34 | .ie n \{\ |
| 35 | . ds -- \(*W- |
| 36 | . ds PI pi |
| 37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch |
| 38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch |
| 39 | . ds L" "" |
| 40 | . ds R" "" |
| 41 | . ds C` "" |
| 42 | . ds C' "" |
| 43 | 'br\} |
| 44 | .el\{\ |
| 45 | . ds -- \|\(em\| |
| 46 | . ds PI \(*p |
| 47 | . ds L" `` |
| 48 | . ds R" '' |
| 49 | 'br\} |
| 50 | .\" |
| 51 | .\" If the F register is turned on, we'll generate index entries on stderr for |
| 52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index |
| 53 | .\" entries marked with X<> in POD. Of course, you'll have to process the |
| 54 | .\" output yourself in some meaningful fashion. |
| 55 | .if \nF \{\ |
| 56 | . de IX |
| 57 | . tm Index:\\$1\t\\n%\t"\\$2" |
| 58 | .. |
| 59 | . nr % 0 |
| 60 | . rr F |
| 61 | .\} |
| 62 | .\" |
| 63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 64 | .\" way too many mistakes in technical documents. |
| 65 | .hy 0 |
| 66 | .if n .na |
| 67 | .\" |
| 68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). |
| 69 | .\" Fear. Run. Save yourself. No user-serviceable parts. |
| 70 | . \" fudge factors for nroff and troff |
| 71 | .if n \{\ |
| 72 | . ds #H 0 |
| 73 | . ds #V .8m |
| 74 | . ds #F .3m |
| 75 | . ds #[ \f1 |
| 76 | . ds #] \fP |
| 77 | .\} |
| 78 | .if t \{\ |
| 79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) |
| 80 | . ds #V .6m |
| 81 | . ds #F 0 |
| 82 | . ds #[ \& |
| 83 | . ds #] \& |
| 84 | .\} |
| 85 | . \" simple accents for nroff and troff |
| 86 | .if n \{\ |
| 87 | . ds ' \& |
| 88 | . ds ` \& |
| 89 | . ds ^ \& |
| 90 | . ds , \& |
| 91 | . ds ~ ~ |
| 92 | . ds / |
| 93 | .\} |
| 94 | .if t \{\ |
| 95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" |
| 96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' |
| 97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' |
| 98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' |
| 99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' |
| 100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' |
| 101 | .\} |
| 102 | . \" troff and (daisy-wheel) nroff accents |
| 103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' |
| 104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' |
| 105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] |
| 106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' |
| 107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' |
| 108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] |
| 109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] |
| 110 | .ds ae a\h'-(\w'a'u*4/10)'e |
| 111 | .ds Ae A\h'-(\w'A'u*4/10)'E |
| 112 | . \" corrections for vroff |
| 113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' |
| 114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' |
| 115 | . \" for low resolution devices (crt and lpr) |
| 116 | .if \n(.H>23 .if \n(.V>19 \ |
| 117 | \{\ |
| 118 | . ds : e |
| 119 | . ds 8 ss |
| 120 | . ds o a |
| 121 | . ds d- d\h'-1'\(ga |
| 122 | . ds D- D\h'-1'\(hy |
| 123 | . ds th \o'bp' |
| 124 | . ds Th \o'LP' |
| 125 | . ds ae ae |
| 126 | . ds Ae AE |
| 127 | .\} |
| 128 | .rm #[ #] #H #V #F C |
| 129 | .\" ======================================================================== |
| 130 | .\" |
| 131 | .IX Title "Tie::Array 3" |
| 132 | .TH Tie::Array 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" |
| 133 | .SH "NAME" |
| 134 | Tie::Array \- base class for tied arrays |
| 135 | .SH "SYNOPSIS" |
| 136 | .IX Header "SYNOPSIS" |
| 137 | .Vb 3 |
| 138 | \& package Tie::NewArray; |
| 139 | \& use Tie::Array; |
| 140 | \& @ISA = ('Tie::Array'); |
| 141 | .Ve |
| 142 | .PP |
| 143 | .Vb 4 |
| 144 | \& # mandatory methods |
| 145 | \& sub TIEARRAY { ... } |
| 146 | \& sub FETCH { ... } |
| 147 | \& sub FETCHSIZE { ... } |
| 148 | .Ve |
| 149 | .PP |
| 150 | .Vb 4 |
| 151 | \& sub STORE { ... } # mandatory if elements writeable |
| 152 | \& sub STORESIZE { ... } # mandatory if elements can be added/deleted |
| 153 | \& sub EXISTS { ... } # mandatory if exists() expected to work |
| 154 | \& sub DELETE { ... } # mandatory if delete() expected to work |
| 155 | .Ve |
| 156 | .PP |
| 157 | .Vb 9 |
| 158 | \& # optional methods - for efficiency |
| 159 | \& sub CLEAR { ... } |
| 160 | \& sub PUSH { ... } |
| 161 | \& sub POP { ... } |
| 162 | \& sub SHIFT { ... } |
| 163 | \& sub UNSHIFT { ... } |
| 164 | \& sub SPLICE { ... } |
| 165 | \& sub EXTEND { ... } |
| 166 | \& sub DESTROY { ... } |
| 167 | .Ve |
| 168 | .PP |
| 169 | .Vb 2 |
| 170 | \& package Tie::NewStdArray; |
| 171 | \& use Tie::Array; |
| 172 | .Ve |
| 173 | .PP |
| 174 | .Vb 1 |
| 175 | \& @ISA = ('Tie::StdArray'); |
| 176 | .Ve |
| 177 | .PP |
| 178 | .Vb 1 |
| 179 | \& # all methods provided by default |
| 180 | .Ve |
| 181 | .PP |
| 182 | .Vb 1 |
| 183 | \& package main; |
| 184 | .Ve |
| 185 | .PP |
| 186 | .Vb 3 |
| 187 | \& $object = tie @somearray,Tie::NewArray; |
| 188 | \& $object = tie @somearray,Tie::StdArray; |
| 189 | \& $object = tie @somearray,Tie::NewStdArray; |
| 190 | .Ve |
| 191 | .SH "DESCRIPTION" |
| 192 | .IX Header "DESCRIPTION" |
| 193 | This module provides methods for array-tying classes. See |
| 194 | perltie for a list of the functions required in order to tie an array |
| 195 | to a package. The basic \fBTie::Array\fR package provides stub \f(CW\*(C`DESTROY\*(C'\fR, |
| 196 | and \f(CW\*(C`EXTEND\*(C'\fR methods that do nothing, stub \f(CW\*(C`DELETE\*(C'\fR and \f(CW\*(C`EXISTS\*(C'\fR |
| 197 | methods that \fIcroak()\fR if the \fIdelete()\fR or \fIexists()\fR builtins are ever called |
| 198 | on the tied array, and implementations of \f(CW\*(C`PUSH\*(C'\fR, \f(CW\*(C`POP\*(C'\fR, \f(CW\*(C`SHIFT\*(C'\fR, |
| 199 | \&\f(CW\*(C`UNSHIFT\*(C'\fR, \f(CW\*(C`SPLICE\*(C'\fR and \f(CW\*(C`CLEAR\*(C'\fR in terms of basic \f(CW\*(C`FETCH\*(C'\fR, \f(CW\*(C`STORE\*(C'\fR, |
| 200 | \&\f(CW\*(C`FETCHSIZE\*(C'\fR, \f(CW\*(C`STORESIZE\*(C'\fR. |
| 201 | .PP |
| 202 | The \fBTie::StdArray\fR package provides efficient methods required for tied arrays |
| 203 | which are implemented as blessed references to an \*(L"inner\*(R" perl array. |
| 204 | It inherits from \fBTie::Array\fR, and should cause tied arrays to behave exactly |
| 205 | like standard arrays, allowing for selective overloading of methods. |
| 206 | .PP |
| 207 | For developers wishing to write their own tied arrays, the required methods |
| 208 | are briefly defined below. See the perltie section for more detailed |
| 209 | descriptive, as well as example code: |
| 210 | .IP "\s-1TIEARRAY\s0 classname, \s-1LIST\s0" 4 |
| 211 | .IX Item "TIEARRAY classname, LIST" |
| 212 | The class method is invoked by the command \f(CW\*(C`tie @array, classname\*(C'\fR. Associates |
| 213 | an array instance with the specified class. \f(CW\*(C`LIST\*(C'\fR would represent |
| 214 | additional arguments (along the lines of AnyDBM_File and compatriots) needed |
| 215 | to complete the association. The method should return an object of a class which |
| 216 | provides the methods below. |
| 217 | .IP "\s-1STORE\s0 this, index, value" 4 |
| 218 | .IX Item "STORE this, index, value" |
| 219 | Store datum \fIvalue\fR into \fIindex\fR for the tied array associated with |
| 220 | object \fIthis\fR. If this makes the array larger then |
| 221 | class's mapping of \f(CW\*(C`undef\*(C'\fR should be returned for new positions. |
| 222 | .IP "\s-1FETCH\s0 this, index" 4 |
| 223 | .IX Item "FETCH this, index" |
| 224 | Retrieve the datum in \fIindex\fR for the tied array associated with |
| 225 | object \fIthis\fR. |
| 226 | .IP "\s-1FETCHSIZE\s0 this" 4 |
| 227 | .IX Item "FETCHSIZE this" |
| 228 | Returns the total number of items in the tied array associated with |
| 229 | object \fIthis\fR. (Equivalent to \f(CW\*(C`scalar(@array)\*(C'\fR). |
| 230 | .IP "\s-1STORESIZE\s0 this, count" 4 |
| 231 | .IX Item "STORESIZE this, count" |
| 232 | Sets the total number of items in the tied array associated with |
| 233 | object \fIthis\fR to be \fIcount\fR. If this makes the array larger then |
| 234 | class's mapping of \f(CW\*(C`undef\*(C'\fR should be returned for new positions. |
| 235 | If the array becomes smaller then entries beyond count should be |
| 236 | deleted. |
| 237 | .IP "\s-1EXTEND\s0 this, count" 4 |
| 238 | .IX Item "EXTEND this, count" |
| 239 | Informative call that array is likely to grow to have \fIcount\fR entries. |
| 240 | Can be used to optimize allocation. This method need do nothing. |
| 241 | .IP "\s-1EXISTS\s0 this, key" 4 |
| 242 | .IX Item "EXISTS this, key" |
| 243 | Verify that the element at index \fIkey\fR exists in the tied array \fIthis\fR. |
| 244 | .Sp |
| 245 | The \fBTie::Array\fR implementation is a stub that simply croaks. |
| 246 | .IP "\s-1DELETE\s0 this, key" 4 |
| 247 | .IX Item "DELETE this, key" |
| 248 | Delete the element at index \fIkey\fR from the tied array \fIthis\fR. |
| 249 | .Sp |
| 250 | The \fBTie::Array\fR implementation is a stub that simply croaks. |
| 251 | .IP "\s-1CLEAR\s0 this" 4 |
| 252 | .IX Item "CLEAR this" |
| 253 | Clear (remove, delete, ...) all values from the tied array associated with |
| 254 | object \fIthis\fR. |
| 255 | .IP "\s-1DESTROY\s0 this" 4 |
| 256 | .IX Item "DESTROY this" |
| 257 | Normal object destructor method. |
| 258 | .IP "\s-1PUSH\s0 this, \s-1LIST\s0" 4 |
| 259 | .IX Item "PUSH this, LIST" |
| 260 | Append elements of \s-1LIST\s0 to the array. |
| 261 | .IP "\s-1POP\s0 this" 4 |
| 262 | .IX Item "POP this" |
| 263 | Remove last element of the array and return it. |
| 264 | .IP "\s-1SHIFT\s0 this" 4 |
| 265 | .IX Item "SHIFT this" |
| 266 | Remove the first element of the array (shifting other elements down) |
| 267 | and return it. |
| 268 | .IP "\s-1UNSHIFT\s0 this, \s-1LIST\s0" 4 |
| 269 | .IX Item "UNSHIFT this, LIST" |
| 270 | Insert \s-1LIST\s0 elements at the beginning of the array, moving existing elements |
| 271 | up to make room. |
| 272 | .IP "\s-1SPLICE\s0 this, offset, length, \s-1LIST\s0" 4 |
| 273 | .IX Item "SPLICE this, offset, length, LIST" |
| 274 | Perform the equivalent of \f(CW\*(C`splice\*(C'\fR on the array. |
| 275 | .Sp |
| 276 | \&\fIoffset\fR is optional and defaults to zero, negative values count back |
| 277 | from the end of the array. |
| 278 | .Sp |
| 279 | \&\fIlength\fR is optional and defaults to rest of the array. |
| 280 | .Sp |
| 281 | \&\fI\s-1LIST\s0\fR may be empty. |
| 282 | .Sp |
| 283 | Returns a list of the original \fIlength\fR elements at \fIoffset\fR. |
| 284 | .SH "CAVEATS" |
| 285 | .IX Header "CAVEATS" |
| 286 | There is no support at present for tied \f(CW@ISA\fR. There is a potential conflict |
| 287 | between magic entries needed to notice setting of \f(CW@ISA\fR, and those needed to |
| 288 | implement 'tie'. |
| 289 | .PP |
| 290 | Very little consideration has been given to the behaviour of tied arrays |
| 291 | when \f(CW$[\fR is not default value of zero. |
| 292 | .SH "AUTHOR" |
| 293 | .IX Header "AUTHOR" |
| 294 | Nick Ing-Simmons <nik@tiuk.ti.com> |