Clownf...:Vector(3pm)
π Clownf...:Vector β bestie edition π
okay so. this is Clownf...:Vector, straight out of the User Contributed Perl Documentation, and she is exactly what she sounds like: a variable-sized array. that's it, that's the whole vibe. a glow-up array that grows when you need her to. no cap. π¦
β¨ SYNOPSIS β¨
my $vector = Clownfish::Vector->new;
$vector->store($tick, $value);
my $value = $vector->fetch($tick);
like. look at her. three lines and she's already storing and fetching. main character energy fr fr π
πΈ DESCRIPTION πΈ
bestie the original literally leaves this section blank π she said "the name says it all" and honestly? she's right. variable-sized array. moving on, the good stuff is below.
π CONSTRUCTORS π
new
my $vector = Clownfish::Vector->new(
capacity => $capacity, # default: 0
);
bestie she's brand new and she's ready. this hands you back a fresh Vector. β¨
capacityβ the initial number of elements she can hold before she has to go get reallocated. the original default is0, so she starts smol and grows into herself. we love a growth arc π±
π METHODS π
push
$vector->push($element);
$vector->push(); # default: undef
push an item onto the end of the Vector. if you pass nothing, the default is undef β she'll happily hold a little void for you, no questions asked π
push_all
$vector->push_all($other);
take every single element from another Vector and push them all onto the end of this one. it's giving "your friends are my friends now". π«Ά
pop
my $obj = $vector->pop();
pop an item off the end of the Vector. bye bestie π
Returns: the element, or undef if the Vector is empty. (empty Vector? she gives you nothing. respectfully.)
insert
$vector->insert(
tick => $tick, # required
element => $element, # default: undef
);
insert an element at tick and move the following elements out of the way. she makes room. she's polite like that. π
insert_all
$vector->insert_all(
tick => $tick, # required
other => $other, # required
);
inserts elements from the other vector at tick, moving the following elements. both tick and other are required β no skipping, she needs the whole picture. π
fetch
my $obj = $vector->fetch($tick);
fetch the element at tick.
Returns: the element, or undef if tick is out of bounds. (out of bounds? she's not mad, she's just gonna hand you undef and pretend nothing happened π)
store
$vector->store($tick, $elem)
store an element at index tick, possibly displacing an existing element. yes, that means something might get yeeted. she said move. π€
delete
my $obj = $vector->delete($tick);
replace an element in the Vector with undef and return it. so the spot stays, it's just... hollow now. spooky but useful π³οΈ
Returns: the element stored at tick, or undef if tick is out of bounds.
excise
$vector->excise(
offset => $offset, # required
length => $length, # required
);
remove length elements from the Vector, starting at offset, and move elements over to fill in the gap. surgical. precise. she closes the wound herself. π©Ή
clone
my $arrayref = $vector->clone();
clone the Vector β but she merely increments the refcounts of its elements rather than clone them. so the elements are shared, not copied, and that is very important, bestie. read it twice. π¨
sort
$vector->sort();
sort the Vector. and here's the tea: sort order is guaranteed to be stable β the relative order of elements which compare as equal will not change. iconic behaviour, no notes. π
resize
$vector->resize($size);
set the size for the Vector. if the new size is larger than the current size, she grows the object to accommodate undef elements; if smaller than the current size, she decrements and discards the truncated elements. so like... resize responsibly, okay? π
clear
$vector->clear();
empty the Vector. poof. gone. she's starting over, it's a healing era π§
get_size
my $int = $vector->get_size();
return the size of the Vector. that's the whole thing. she tells you how big she is and she's not weird about it. π
slice
my $arrayref = $vector->slice(
offset => $offset, # required
length => $length, # required
);
return a slice of the Vector consisting of elements from a contiguous range. and here's the twist β if the specified range is out of bounds, she returns a slice with fewer elements β potentially none. she gives what she has and no more. π
offsetβ the index of the element to start at.lengthβ the maximum number of elements to slice.
π INHERITANCE π
Clownfish::Vector isa Clownfish::Obj.
family tree says she gets it from Clownfish::Obj and honestly you can tell. π«Ά
and that's the whole page, bestie!! this one's from perl v5.42.3, dated 2026-09-02, and it lives under Clownf...:Vector(3pm). go forth and be variable-sized. mwah πβ¨π
π¦ where this page comes from
- fedora 43: perl-Clownfish 0.8.0-1.fc43 Β· Apache-2.0
- fedora 44: perl-Clownfish 0.8.0-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms