SPVM::QList(3)
π SPVM::QList β like, the whole page, bestie
Okay so this is SPVM::QList(3), straight out of the User Contributed Perl Documentation manual, and it's genuinely one of my faves, no cap. It's a List class in SPVM with an O(1) deque. Yes. That's the whole personality. Obsessed.
πΈ Name
SPVM::QList β a List with an O(1) deque. That's it, that's the icon.
β¨ Usage
Bestie, just start with use QList; and you're in. Here's the full tour:
use QList;
# Create an object list
my $list = QList->new;
my $list = QList->new([(object)Byte->new(1), Int->new(2), Long->new(3)]);
# Create a Int list
my $list = QList->new([Int->new(1), Int->new(2), Int->new(3)]);
# Create an object list with length
my $list = QList->new_len([], 3);
# Create a Int list with length
my $list = QList->new_len(new Int[0], 3);
# Get list length
my $length = $list->length;
# Push object value
$list->push(Int->new(3));
# Pop object value.
my $element = $list->pop;
# Unshift object value.
$list->unshift(Int->new(3));
# Shift object value.
my $element = $list->shift;
# Set object value.
$list->set(2, Int->new(3));
# Get object value.
my $element = $list->get(2);
# Insert object value
$list->insert(1, Int->new(3));
# Remove object value
my $element = $list->remove(1);
# Convert QList to object array.
my $int_array = $list->to_array;
# Convert QList to Int array.
my $int_array = (Int[])$list->to_array;
Like, every single one of those is right there. Copy responsibly π
π¦ Description
So, QList in SPVM is a List class, but make it β¨O(1) dequeβ¨. Same energy as List, just faster at the ends. Main character behaviour honestly.
π Details
π« O(1) deque
The shift method is O(1) instead of the List class's version. That's the whole flex, and honestly? It ate.
π Super Class
List
Yes, it's giving inheritance. She gets it from her mama.
β Class methods
π new
"static method new : QList ($array : object[] = undef, $capacity : int = -1);"
π new_len
"static method new_len : QList ($proto_array : object[], $length : int, $capacity : int = -1);"
π Instance methods
π get
"method get : element ($index : int);"
Same as List#get method.
π set
"method set : void ($index : int, $element : object);"
Same as List#set method.
π shift
"method shift : element ();"
Same as List#shift method. (And remember β over here it's O(1) π
)
π to_array
"method to_array : element[] ();"
Same as List#to_array method.
π unshift
"method unshift : void ($element : object);"
Same as List#unshift method.
π clone
"method clone : QList ();"
Same as List#clone method.
π get_array
"method get_array : element[] ();"
Okay so this one is a little dramatic: it always throw an exception. Like, always. No exceptions to the exception π
Exceptions:
Cannot get the internal array in QList object.
Lowkey important caveat bestie: this method never succeeds β if you call get_array, you get that exception message. So maybe... don't.
π«Ά Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License
πΈ okay that's the whole page, you're officially educated, iykyk πΈ
And a cute little sign-off for the footer energy: this one's from perl v5.42.2, dated 2026-02-03, page SPVM::QList(3) β go forth and deque responsibly, bestie πβ¨π
π¦ where this page comes from
- alpine 3.24: spvm-doc 0.990125-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms