Clownf...:Vector(3pm)

πŸ“¦
version 0.8.0 Β· 3 versions
, in fedora 43, fedora 44

πŸ’– 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 is 0, 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