<commit_before>/*
* Copyright (C) 2014 - <NAME> <<EMAIL>>
*
* This sofware is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/

import Vector

VectorList: class <T> {
	_vector: Vector<T>
	_count: Int
	count ::= this _count
	pointer ::= this _vector _backend as Pointer
	empty ::= this _count == 0
	init: func ~default {
		this init(32)
	}
	init: func ~heap (capacity: Int) {
		this init(HeapVector<T> new(capacity))
	}
	init: func (=_vector)

	add: func (item: T) {
		if (this _vector capacity <= this _count)
			this _vector resize(this _vector capacity + 8)
		this _vector[this _count] = item
		this _count += 1
	}
	insert: func (index: Int, item: T) {
		if (this _vector capacity <= this _count)
			this _vector resize(this _vector capacity + 8)
		this _vector copy(index, index + 1)
		this _vector[index] = item
		this _count += 1
	}
	remove: func ~last -> T {
		this _count -= 1
		this _vector[this _count]
	}
	remove: func ~atIndex (index: Int) -> T {
		result := this _vector[index]
		this _vector copy(index + 1, index)
		this _count -= 1
		result
	}
	clear: func {
		this _vector _free(0, this _count)
		this _count = 0
	}
	free: override func {
		this _vector _free(0, this _count)<commit_msg>Readded removeAt.<commit_after>/*
* Copyright (C) 2014 - <NAME> <<EMAIL>>
*
* This sofware is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/

import Vector

VectorList: class <T> {
	_vector: Vector<T>
	_count: Int
	count ::= this _count
	pointer ::= this _vector _backend as Pointer
	empty ::= this _count == 0
	init: func ~default {
		this init(32)
	}
	init: func ~heap (capacity: Int) {
		this init(HeapVector<T> new(capacity))
	}
	init: func (=_vector)

	add: func (item: T) {
		if (this _vector capacity <= this _count)
			this _vector resize(this _vector capacity + 8)
		this _vector[this _count] = item
		this _count += 1
	}
	insert: func (index: Int, item: T) {
		if (this _vector capacity <= this _count)
			this _vector resize(this _vector capacity + 8)
		this _vector copy(index, index + 1)
		this _vector[index] = item
		this _count += 1
	}
	remove: func ~last -> T {
		this _count -= 1
		this _vector[this _count]
	}
	remove: func ~atIndex (index: Int) -> T {
		result := this _vector[index]
		this _vector copy(index + 1, index)
		this _count -= 1
		result
	}
	removeAt: func (index: Int) {
		this _vector copy(index+1, index)
		this _count -= 1
	}
	clear: func {
		this _vector _free(0, this _count)
		this _count = 0
	}
	free: override func {
		this _vector _free(0, this _count)
{'fraction_non_alphanumeric': 0.10067842605156038, 'fraction_numerical': 0.011397557666214383, 'mean_word_length': 3.6895674300254453, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7466326', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1171, 'n_words': 499}