<commit_before>/**    / \____  _    ______   _____ / \____   ____  _____
 *    /  \__  \/ \  / \__  \ /  __//  \__  \ /    \/ __  \   Javaslang
 *  _/  // _\  \  \/  / _\  \\_  \/  // _\  \  /\  \__/  /   Copyright 2014 <NAME>
 * /___/ \_____/\____/\_____/____/\___\_____/_/  \_/____/    Licensed under the Apache License, Version 2.0
 */
package javaslang.collection;

import static javaslang.Lang.requireNonNull;

import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
 * TODO: need a Collector for terminal stream operations for this List type
 * 
 * TODO: javadoc
 * 
 * @param <T> Component type of this list
 */
public interface List<T> extends Iterable<T> {

	T head();

	List<T> tail();

	boolean isEmpty();

	default List<T> append(T element) {
		return reverse().prepend(element).reverse();
	}

	default List<T> prepend(T element) {
		return new LinearList<>(element, this);
	}
	
	// TODO: insert(index, element)
	
	// TODO: set(index, element)
	
	// TODO: remove(element)
	
	// TODO: implement equals(Object), hashCode()

	/**
	 * Calculates the size of a List in O(n).
	 * 
	 * @return The size of this List.
	 */
	default int size() {
		return isEmpty() ? 0 : 1 + tail().size();
	}

	default boolean contains(T o) {
		List<T> list = this;
		while (!list.isEmpty()) {
			final T head = list.head();
			if (head == o || (head != null && head.equals(o))) {
				return true;
			}
			list = list.tail();
		}
		return false;
	}

	default T get(int index) {
		if (index < 0 || index >= size()) {
			throw new IndexOutOfBoundsException("No element at specified index: " + index);
		}
		List<T> list = this;
		int currentIndex = index;
		while (currentIndex > 0) {
			currentIndex--;
			list = list.tail();
		}
		return list.head();
	}

	default int indexOf(T o) {
		List<T> list = this;
		int index = 0;
		while (!list.isEmpty()) {
			final T head = head();
			if (head == o || (head != null && head.equals(o))) {<commit_msg>removed redundant code<commit_after>/**    / \____  _    ______   _____ / \____   ____  _____
 *    /  \__  \/ \  / \__  \ /  __//  \__  \ /    \/ __  \   Javaslang
 *  _/  // _\  \  \/  / _\  \\_  \/  // _\  \  /\  \__/  /   Copyright 2014 <NAME>
 * /___/ \_____/\____/\_____/____/\___\_____/_/  \_/____/    Licensed under the Apache License, Version 2.0
 */
package javaslang.collection;

import static javaslang.Lang.requireNonNull;

import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
 * TODO: need a Collector for terminal stream operations for this List type
 * 
 * TODO: javadoc
 * 
 * @param <T> Component type of this list
 */
public interface List<T> extends Iterable<T> {

	T head();

	List<T> tail();

	boolean isEmpty();

	default List<T> append(T element) {
		return reverse().prepend(element).reverse();
	}

	default List<T> prepend(T element) {
		return new LinearList<>(element, this);
	}
	
	// TODO: insert(index, element)
	
	// TODO: set(index, element)
	
	// TODO: remove(element)
	
	// TODO: implement equals(Object), hashCode()

	/**
	 * Calculates the size of a List in O(n).
	 * 
	 * @return The size of this List.
	 */
	default int size() {
		return isEmpty() ? 0 : 1 + tail().size();
	}

	default boolean contains(T o) {
		return indexOf(o) != -1;
	}

	default T get(int index) {
		if (index < 0 || index >= size()) {
			throw new IndexOutOfBoundsException("No element at specified index: " + index);
		}
		List<T> list = this;
		int currentIndex = index;
		while (currentIndex > 0) {
			currentIndex--;
			list = list.tail();
		}
		return list.head();
	}

	default int indexOf(T o) {
		List<T> list = this;
		int index = 0;
		while (!list.isEmpty()) {
			final T head = head();
			if (head == o || (head != null && head.equals(o))) {
{'fraction_non_alphanumeric': 0.15952917605810168, 'fraction_numerical': 0.00576008014024543, 'mean_word_length': 2.644160583941606, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3511028', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1370, 'n_words': 358}