™.. Class::MethodMaker::array - Online Linux Manual PageSection : 3
Updated : 2014-05-22
Source : perl v5.10.1
Note : User Contributed Perl Documentation
NAMEClass::Method::array − Create methods for handling an array value.
SYNOPSIS use Class::MethodMaker
[ array => [qw/ x /] ];
$instance−>x; # empty
$instance−>x(1, 1, 2, 3, 5, 8);
$instance−>x_count == 6; # true
$instance−>x = (13, 21, 34);
$instance−>x_index(1) == 21; # true
DESCRIPTIONCreates methods to handle array values in an object. For a component named \*(C`x\*(C'\fR, by default creates methods \f(CW\*(C`x\*(C'\fR, \f(CW\*(C`x_reset\*(C'\fR, \f(CW\*(C`x_clear\*(C'\fR, \f(CW\*(C`x_isset\*(C'\fR, \*(C`x_count\*(C'\fR, \f(CW\*(C`x_index\*(C'\fR, \f(CW\*(C`x_push\*(C'\fR, \f(CW\*(C`x_pop\*(C'\fR, \f(CW\*(C`x_unshift\*(C'\fR, \f(CW\*(C`x_shift\*(C'\fR, \*(C`x_splice\*(C'\fR. Methods available are: \*(C`*\*(C'\fI\fR Created by default. This method returns the list of values stored in the slot. If any arguments are provided to this method, they replace the current list contents. In an array context it returns the values as an array and in a scalar context as a reference to an array. Note that this reference is no longer a direct reference to the storage, in contrast to Class::MethodMaker v1. This is to protect encapsulation. See x_ref if you need that functionality (and are prepared to take the associated risk.) This function no longer auto-expands arrayrefs input as arguments, since that makes it awkward to set individual values to arrayrefs. See x_setref for that functionality. If a default value is in force, then that value will be auto-vivified (and therefore set) for each otherwise unset (not not defined) value up to the array max (so new items will not be appended) *_reset Created by default. Called without an argument, this resets the component as a whole; deleting any associated storage, and returning the component to its default state. Normally, this means that *_isset will return false, and \*(C`*\*(C'\fR will return undef. If \f(CW\*(C`\-default\*(C'\fR is in effect, then the component will be set to the default value, and *_isset will return true. If \*(C`\-default_ctor\*(C'\fR is in effect, then the default subr will be invoked, and its return value used to set the value of the component, and *_isset will return true. If called with arguments, these arguments are treated as indexes into the component, and the individual elements thus referenced are reset (their storage deleted, so that *_isset(n) will return false for appropriate n, except where \*(C`\-default\*(C'\fR or \f(CW\*(C`\-default_ctor\*(C'\fR are in force, as above). As with perl arrays, resetting the highest set value implicitly decreases the count (but x_reset(n) never unsets the aggregate itself, even if all the elements are not set). *_clear package MyClass;
use Class::MethodMaker
[ scalar => [{'*_clear' => '*_clear'}, 'a'],
new => new, ];
package main;
my $m = MyClass−>new;
$m−>a(5);
$a = $m−>a; # 5
$x = $m−>a_isset; # true
$m−>a_clear;
$a = $m−>a; # *undef*
$x = $m−>a_isset; # true
Created on request. A shorthand for setting to undef. Note that the component will be set to undef, not reset, so *_isset will return true. *_isset Created by default. Whether the component is currently set. This is different from being defined; initially, the component is not set (and if read, will return undef); it can be set to undef (which is a set value, which also returns undef). Having been set, the only way to unset the component is with <*_reset>. If a default value is in effect, then <*_isset> will always return true. \*(C`*_isset()\*(C'\fR tests the component as a whole. \f(CW*_isset(a)\fR tests the element indexed by a. \*(C`*_isset(a,b)\*(C'\fR tests the elements indexed by \fIa\fR, \fIb\fR, and returns the logical conjunction (and) of the tests. *_count Created by default. Returns the number of elements in this component. This is not affected by presence (or lack) of a \*(C`default\*(C'\fR (or \f(CW\*(C`default_ctor\*(C'\fR). Returns \*(C`undef\*(C'\fR if whole component not set (as per \f(CW*_isset\fR). *_index Created by default. Takes a list of indices, returns a list of the corresponding values. If a default (or a default ctor) is in force, then a lookup by index will vivify & set to the default the respective elements (and therefore the aggregate data-structure also, if it's not already). Beware of a bug in perl 5.6.1 that will sometimes invent values in previously unset slots of arrays that previously contained a value. So, vivifying a value (e.g. by x_index (2)) where x_index (1) was previously unset might cause x_index (1) to be set spuriously. This is fixed in 5.8.0. *_push Created by default. Push item(s) onto the end of the list. No return value. *_pop Created by default. Given a number, pops that many items off the end of the list, and returns them (as a ref in scalar context, as a list in list context). Without an arg, always returns a single element. Given a number, returns them in array order (not in reverse order as multiple pops would). *_unshift Created by default. Push item(s) onto the start of the list. No return value. *_shift Created by default. Given a number, shifts that many items off the start of the list, and returns them (as a ref in scalar context, as a list in list context). Without an arg, always returns a single element. Given a number, returns them in array order. *_splice Created by default. Arguments as for perldoc perlfunc splice. Returns an arrayref in scalar context (even if a single item is spliced), and a list in list context. *_get Created on request. Retrieves the value of the component without setting (ignores any arguments passed). *_set @n = $x−>a; # (1,2,3)
$x−>a_set(1=>4,3=>7);
@n = $x−>a; # (1,4,3,7)
Created by default. Takes a list, treated as pairs of index => value; each given index is set to the corresponding value. No return. If two arguments are given, of which the first is an arrayref, then it is treated as a list of indices of which the second argument (which must also be an arrayref) are the corresponding values. Thus the following two commands are equivalent: $x−>a_set(1=>4,3=>7);
$x−>a_set([1,3],[4,7]);
0
Johanes Gumabo
Data Size : 22,874 byte
man-Class::MethodMaker::array.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 6 / 180,959
Visitor ID : :
Visitor IP : 3.144.21.237 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Class::MethodMaker::array.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Class::MethodMaker::array.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Class::MethodMaker::array.3pm|41|br══─}─══|'br══─}─══
) (htmlprn|149|Class::MethodMaker::array.3pm|41|'br══─}─══ |'br══─}─══
) (rof_nr_x|149|Class::MethodMaker::array.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (rof_unit_scale_px|41|Class::MethodMaker::array.3pm|51/52|F|.ie \nF ══─{─══. de IX
) (rof_if|19|Class::MethodMaker::array.3pm|51/52|\nF|.ie \nF ══─{─══. de IX
) (htmlprn|149|Class::MethodMaker::array.3pm|51/52|.ie \nF ══─{─══. de IX|.ie \nF ══─{─══. de IX
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|53|\$1\t\\n%\t"\\$2" |. tm Index:\\$1\t\\n%\t"\\$2"
) (parse_manual_page_|249|Class::MethodMaker::array.3pm|57|══─}─══|.══─}─══
) (htmlprn|149|Class::MethodMaker::array.3pm|57|.══─}─══ |.══─}─══
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|149|\*(C`x\*(C'\fR, by default creates methods \f(CW\*(C`x\*(C'\fR, \f(CW\*(C`x_reset\*(C'\fR, \f(CW\*(C`x_clear\*(C'\fR, \f(CW\*(C`x_isset\*(C'\fR, |\&\f(CW\*(C`x\*(C'\fR, by default creates methods \f(CW\*(C`x\*(C'\fR, \f(CW\*(C`x_reset\*(C'\fR, \f(CW\*(C`x_clear\*(C'\fR, \f(CW\*(C`x_isset\*(C'\fR,
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|150|\*(C`x_count\*(C'\fR, \f(CW\*(C`x_index\*(C'\fR, \f(CW\*(C`x_push\*(C'\fR, \f(CW\*(C`x_pop\*(C'\fR, \f(CW\*(C`x_unshift\*(C'\fR, \f(CW\*(C`x_shift\*(C'\fR, |\&\f(CW\*(C`x_count\*(C'\fR, \f(CW\*(C`x_index\*(C'\fR, \f(CW\*(C`x_push\*(C'\fR, \f(CW\*(C`x_pop\*(C'\fR, \f(CW\*(C`x_unshift\*(C'\fR, \f(CW\*(C`x_shift\*(C'\fR,
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|151|\*(C`x_splice\*(C'\fR. |\&\f(CW\*(C`x_splice\*(C'\fR.
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|155|\*(C`*\*(C'\fI\fR |\fI\f(CI\*(C`*\*(C'\fI\fR
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|179|\*(C`*\*(C'\fR will return undef. If \f(CW\*(C`\-default\*(C'\fR is in effect, then the component |and \f(CW\*(C`*\*(C'\fR will return undef. If \f(CW\*(C`\-default\*(C'\fR is in effect, then the component
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|181|\*(C`\-default_ctor\*(C'\fR is in effect, then the default subr will be invoked, and its |\&\f(CW\*(C`\-default_ctor\*(C'\fR is in effect, then the default subr will be invoked, and its
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|188|\*(C`\-default\*(C'\fR or \f(CW\*(C`\-default_ctor\*(C'\fR are in force, as above). As with |except where \f(CW\*(C`\-default\*(C'\fR or \f(CW\*(C`\-default_ctor\*(C'\fR are in force, as above). As with
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|226|\*(C`*_isset()\*(C'\fR tests the component as a whole. \f(CW*_isset(a)\fR tests the element |\&\f(CW\*(C`*_isset()\*(C'\fR tests the component as a whole. \f(CW*_isset(a)\fR tests the element
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|227|\*(C`*_isset(a,b)\*(C'\fR tests the elements indexed by \fIa\fR, \fIb\fR, |indexed by \fIa\fR. \f(CW\*(C`*_isset(a,b)\*(C'\fR tests the elements indexed by \fIa\fR, \fIb\fR,
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|234|\*(C`default\*(C'\fR (or \f(CW\*(C`default_ctor\*(C'\fR). |is not affected by presence (or lack) of a \f(CW\*(C`default\*(C'\fR (or \f(CW\*(C`default_ctor\*(C'\fR).
) (rof_escape_sequence|91|Class::MethodMaker::array.3pm|235|\*(C`undef\*(C'\fR if whole component not set (as per \f(CW*_isset\fR). |Returns \f(CW\*(C`undef\*(C'\fR if whole component not set (as per \f(CW*_isset\fR).
)