# Copyright (c) 2023 Yuki Kimoto
# MIT License
class StringList extends List {
use Fn;
use Array;
# Class methods
static method new : StringList ($array : string[] = undef, $capacity : int = -1) {
my $self = new StringList;
unless ($array) {
$array = new string[0];
}
$self->SUPER::init($array, $capacity);
return $self;
}
static method new_len : StringList ($length : int, $capacity : int = -1) {
my $self = new StringList;
my $proto = new string[0];
$self->SUPER::init_len($proto, $length, $capacity);
return $self;
}
# Instance methods
method get : string ($index : int) {
return (string)$self->SUPER::get($index);
}
method insert : void ($index : int, $element : string) {
$self->SUPER::insert($index, $element);
}
method pop : string () {
return (string)$self->SUPER::pop;
}
method push : void ($element : string) {
$self->SUPER::push($element);
}
method remove : string ($index : int) {
return (string)$self->SUPER::remove($index);
}
method replace : void ($offset : int, $remove_length : int, $replace : string[]) {
$self->SUPER::replace($offset, $remove_length, $replace);
}
method set : void ($index : int, $element : string) {
$self->SUPER::set($index, $element);
}
method shift : string () {
return (string)$self->SUPER::shift;
}
method to_array : string[] () {
return (string[])$self->SUPER::to_array;
}
method unshift : void ($element : string) {
$self->SUPER::unshift($element);
}
}