NAME
HAMT::Vector::Transient - a vector opened for a batch of updates
VERSION
Version 0.03
SYNOPSIS
use HAMT::Vector;
my $v = HAMT::Vector->new('a');
my $t = $v->transient;
$t->push($_) for 1 .. 100_000;
$t->set(0, 'A');
my $v2 = $t->persistent;
$v->count; # 1: the vector it was opened from is unchanged
$v2->count; # 100001
DESCRIPTION
A HAMT::Vector that is changed in place for a while, and then closed into an ordinary vector that never changes again. It is to a vector what HAMT::Map::Transient is to a map, and that page says when one is worth using.
It is made by "transient" in HAMT::Vector. The vector it was opened from is not affected by anything done to it, and neither is any other transient opened from the same vector.
"push", "set" and "pop" return the transient itself and do not warn in void context. A transient has no list, each or equals, and no concat, slice, insert or remove: call "persistent" first.
A value that is replaced or popped is let go at once, unless some vector still holds it.
METHODS
push
$t->push($value);
$t->push(@values)->push($another);
Adds the values at the end and returns the transient.
pop
$t->pop;
Removes the last value and returns the transient. Popping an empty transient leaves it empty.
set
$t->set($index, $value);
Replaces the value at the index and returns the transient. The index has to name an element that is there, as for "set" in HAMT::Vector.
get
my $value = $t->get($index);
The value at the index, or undef when there is none there.
count
my $n = $t->count;
The number of values.
persistent
my $v = $t->persistent;
An ordinary vector holding what the transient holds, of the class of the vector the transient was opened from. This does not copy anything.
The transient is closed by it. Every method called on a closed transient dies with this transient is closed.
THREADS
A transient belongs to the interpreter that made it and is not inherited by a new thread.
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-hamt at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=HAMT.
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION.
This is free software, licensed under the Artistic License 2.0.