class TestCase::GenericList<T> {
  has values : object[];
  has length : int;
  has capacity : int;

  static method new : TestCase::List ($capacity : int) {
    my $self = new TestCase::List;
    
    $self->{capacity} = $capacity;
    
    $self->{values} = new object[$capacity];
    
    return $self;
  }
  
  method add : void ($object : T) {
    my $length = $self->{length};
    my $capacity = $self->{capacity};
    
    if ($length >= $capacity) {
      my $new_capacity = $capacity * 2;
      $self->{values} = new object[$new_capacity];
      $self->{capacity} = $new_capacity;
    }
    
    $self->{values}[$length] = $object;
    
    $self->{length} = $self->{length} + 1;
  }
  
  method get_values : T[] () {
    my $values : T[];
    for (my $i = 0; $i < $self->length; $i++) {
      $values->[$i] = $self->values->[$i];
    }
    
    return $values;
  }
  
  
  method get : T ($index : int) {
    return $self->{values}[$index];
  }
}
