All Downloads are FREE. Search and download functionalities are using the official Maven repository.

drv.List.drv Maven / Gradle / Ivy

Go to download

fastutil extends the Java Collections Framework by providing type-specific maps, sets, lists and priority queues with a small memory footprint and fast access and insertion; provides also big (64-bit) arrays, sets and lists, and fast, practical I/O classes for binary and text files.

There is a newer version: 8.5.15
Show newest version
/*
 * Copyright (C) 2002-2017 Sebastiano Vigna
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package PACKAGE;

import java.util.List;

#if ! KEY_CLASS_Reference

/** A type-specific {@link List}; provides some additional methods that use polymorphism to avoid (un)boxing.
 *
 * 

Note that this type-specific interface extends {@link Comparable}: it is expected that implementing * classes perform a lexicographical comparison using the standard operator "less then" for primitive types, * and the usual {@link Comparable#compareTo(Object) compareTo()} method for objects. * *

Additionally, this interface strengthens {@link #listIterator()}, * {@link #listIterator(int)} and {@link #subList(int,int)}. * *

Besides polymorphic methods, this interfaces specifies methods to copy into an array or remove contiguous * sublists. Although the abstract implementation of this interface provides simple, one-by-one implementations * of these methods, it is expected that concrete implementation override them with optimized versions. * * @see List */ public interface LIST KEY_GENERIC extends List, Comparable>, COLLECTION KEY_GENERIC { #else /** A type-specific {@link List}; provides some additional methods that use polymorphism to avoid (un)boxing. * *

Additionally, this interface strengthens {@link #iterator()}, {@link #listIterator()}, * {@link #listIterator(int)} and {@link #subList(int,int)}. The former had been already * strengthened upstream, but unfortunately {@link List} re-specifies it. * *

Besides polymorphic methods, this interfaces specifies methods to copy into an array or remove contiguous * sublists. Although the abstract implementation of this interface provides simple, one-by-one implementations * of these methods, it is expected that concrete implementation override them with optimized versions. * * @see List */ public interface LIST KEY_GENERIC extends List, COLLECTION KEY_GENERIC { #endif /** Returns a type-specific iterator on the elements of this list. * *

Note that this specification strengthens the one given in {@link List#iterator()}. * It would not be normally necessary, but {@link java.lang.Iterable#iterator()} is bizarrily re-specified * in {@link List}. * * @return an iterator on the elements of this list. */ @Override KEY_LIST_ITERATOR KEY_GENERIC iterator(); /** Returns a type-specific list iterator on the list. * * @see List#listIterator() */ @Override KEY_LIST_ITERATOR KEY_GENERIC listIterator(); /** Returns a type-specific list iterator on the list starting at a given index. * * @see List#listIterator(int) */ @Override KEY_LIST_ITERATOR KEY_GENERIC listIterator(int index); /** Returns a type-specific view of the portion of this list from the index {@code from}, inclusive, to the index {@code to}, exclusive. * *

Note that this specification strengthens the one given in {@link List#subList(int,int)}. * * @see List#subList(int,int) */ @Override LIST KEY_GENERIC subList(int from, int to); /** Sets the size of this list. * *

If the specified size is smaller than the current size, the last elements are * discarded. Otherwise, they are filled with 0/{@code null}/{@code false}. * * @param size the new size. */ void size(int size); /** Copies (hopefully quickly) elements of this type-specific list into the given array. * * @param from the start index (inclusive). * @param a the destination array. * @param offset the offset into the destination array where to store the first element copied. * @param length the number of elements to be copied. */ void getElements(int from, KEY_TYPE a[], int offset, int length); /** Removes (hopefully quickly) elements of this type-specific list. * * @param from the start index (inclusive). * @param to the end index (exclusive). */ void removeElements(int from, int to); /** Add (hopefully quickly) elements to this type-specific list. * * @param index the index at which to add elements. * @param a the array containing the elements. */ void addElements(int index, KEY_GENERIC_TYPE a[]); /** Add (hopefully quickly) elements to this type-specific list. * * @param index the index at which to add elements. * @param a the array containing the elements. * @param offset the offset of the first element to add. * @param length the number of elements to add. */ void addElements(int index, KEY_GENERIC_TYPE a[], int offset, int length); #if KEYS_PRIMITIVE /** Appends the specified element to the end of this list (optional operation). * @see List#add(Object) */ @Override boolean add(KEY_TYPE key); /** Inserts the specified element at the specified position in this list (optional operation). * @see List#add(int,Object) */ void add(int index, KEY_TYPE key); /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default void add(int index, KEY_CLASS key) { add(index, KEY_CLASS2TYPE(key)); } /** Inserts all of the elements in the specified type-specific collection into this type-specific list at the specified position (optional operation). * @see List#addAll(int,java.util.Collection) */ boolean addAll(int index, COLLECTION c); /** Inserts all of the elements in the specified type-specific list into this type-specific list at the specified position (optional operation). * @see List#add(int,Object) */ boolean addAll(int index, LIST c); /** Appends all of the elements in the specified type-specific list to the end of this type-specific list (optional operation). * @see List#add(int,Object) */ boolean addAll(LIST c); /** Replaces the element at the specified position in this list with the specified element (optional operation). * @see List#set(int,Object) */ KEY_TYPE set(int index, KEY_TYPE k); /** Returns the element at the specified position in this list. * @see List#get(int) */ KEY_TYPE GET_KEY(int index); /** Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. * @see List#indexOf(Object) */ int indexOf(KEY_TYPE k); /** Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. * @see List#lastIndexOf(Object) */ int lastIndexOf(KEY_TYPE k); /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default boolean contains(final Object key) { return COLLECTION.super.contains(key); } /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default KEY_GENERIC_CLASS get(int index) { return KEY2OBJ(GET_KEY(index)); } /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default int indexOf(Object o) { return indexOf(KEY_OBJ2TYPE(o)); } /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default int lastIndexOf(Object o) { return lastIndexOf(KEY_OBJ2TYPE(o)); } /** {@inheritDoc} *

This method specification is a workaround for * bug 8177440. * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default boolean add(KEY_CLASS k) { return add(KEY_CLASS2TYPE(k)); } /** Removes the element at the specified position in this list (optional operation). * @see List#remove(int) */ KEY_TYPE REMOVE_KEY(int index); /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default boolean remove(final Object key) { return COLLECTION.super.remove(key); } /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default KEY_GENERIC_CLASS remove(int index) { return KEY2OBJ(REMOVE_KEY(index)); } /** {@inheritDoc} * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default KEY_GENERIC_CLASS set(int index, KEY_CLASS k) { return KEY2OBJ(set(index, KEY_CLASS2TYPE(k))); } #endif }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy