SPVM::QList(3)

πŸ“¦ version 0.990125, in alpine 3.24

πŸ’… 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 (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