1Clownfish::Vector(3)  User Contributed Perl Documentation Clownfish::Vector(3)
2
3
4

NAME

6       Clownfish::Vector - Variable-sized array.
7

SYNOPSIS

9           my $vector = Clownfish::Vector->new;
10           $vector->store($tick, $value);
11           my $value = $vector->fetch($tick);
12

DESCRIPTION

CONSTRUCTORS

15   new
16           my $vector = Clownfish::Vector->new(
17               capacity => $capacity,  # default: 0
18           );
19
20       Return a new Vector.
21
22       ·   capacity - Initial number of elements that the object will be able
23           to hold before reallocation.
24

METHODS

26   push
27           $vector->push($element);
28           $vector->push();  # default: undef
29
30       Push an item onto the end of a Vector.
31
32   push_all
33           $vector->push_all($other);
34
35       Push all the elements of another Vector onto the end of this one.
36
37   pop
38           my $obj = $vector->pop();
39
40       Pop an item off of the end of a Vector.
41
42       Returns: the element or undef if the Vector is empty.
43
44   insert
45           $vector->insert(
46               tick    => $tick,     # required
47               element => $element,  # default: undef
48           );
49
50       Insert an element at "tick" moving the following elements.
51
52   insert_all
53           $vector->insert_all(
54               tick  => $tick,   # required
55               other => $other,  # required
56           );
57
58       Inserts elements from "other" vector at "tick" moving the following
59       elements.
60
61   fetch
62           my $obj = $vector->fetch($tick);
63
64       Fetch the element at "tick".
65
66       Returns: the element or undef if "tick" is out of bounds.
67
68   store
69           $vector->store($tick, $elem)
70
71       Store an element at index "tick", possibly displacing an existing
72       element.
73
74   delete
75           my $obj = $vector->delete($tick);
76
77       Replace an element in the Vector with undef and return it.
78
79       Returns: the element stored at "tick" or undef if "tick" is out of
80       bounds.
81
82   excise
83           $vector->excise(
84               offset => $offset,  # required
85               length => $length,  # required
86           );
87
88       Remove "length" elements from the Vector, starting at "offset".  Move
89       elements over to fill in the gap.
90
91   clone
92           my $arrayref = $vector->clone();
93
94       Clone the Vector but merely increment the refcounts of its elements
95       rather than clone them.
96
97   sort
98           $vector->sort();
99
100       Sort the Vector.  Sort order is guaranteed to be stable: the relative
101       order of elements which compare as equal will not change.
102
103   resize
104           $vector->resize($size);
105
106       Set the size for the Vector.  If the new size is larger than the
107       current size, grow the object to accommodate undef elements; if smaller
108       than the current size, decrement and discard truncated elements.
109
110   clear
111           $vector->clear();
112
113       Empty the Vector.
114
115   get_size
116           my $int = $vector->get_size();
117
118       Return the size of the Vector.
119
120   slice
121           my $arrayref = $vector->slice(
122               offset => $offset,  # required
123               length => $length,  # required
124           );
125
126       Return a slice of the Vector consisting of elements from a contiguous
127       range.  If the specified range is out of bounds, return a slice with
128       fewer elements X potentially none.
129
130       ·   offset - The index of the element to start at.
131
132       ·   length - The maximum number of elements to slice.
133

INHERITANCE

135       Clownfish::Vector isa Clownfish::Obj.
136
137
138
139perl v5.28.1                      2019-02-02              Clownfish::Vector(3)
Impressum