Each List implementation can be now turned off. Or all Lists can be turned off. ListIterator can't be turned of since it is a IndexBasedIterator and not a List and a few implementation use them.
44 lines
1.3 KiB
Plaintext
44 lines
1.3 KiB
Plaintext
package speiger.src.collections.PACKAGE.utils;
|
|
|
|
import java.util.Objects;
|
|
import java.util.function.Consumer;
|
|
|
|
import speiger.src.collections.utils.IArray;
|
|
|
|
/**
|
|
* Type-Specific Helper class to get the underlying array of array implementations.
|
|
#if ARRAY_LIST_FEATURE
|
|
* @see speiger.src.collections.PACKAGE.lists.ARRAY_LIST
|
|
#endif
|
|
* @Type(T)
|
|
*/
|
|
public interface IARRAY KEY_GENERIC_TYPE extends IArray
|
|
{
|
|
/**
|
|
* Provides the Underlying Array in the Implementation
|
|
* @return underlying Array
|
|
* @throws ClassCastException if the return type does not match the underlying array. (Only for Object Implementations)
|
|
*/
|
|
public KEY_TYPE[] elements();
|
|
|
|
#if TYPE_OBJECT
|
|
/**
|
|
* Method to indicate if the function is save to use
|
|
* @return true if the object is castable to the type that is requested
|
|
*/
|
|
public boolean isCastable();
|
|
#endif
|
|
/**
|
|
* Provides the Underlying Array in the Implementation. This function exists purely because of Synchronization wrappers to help run Synchronized Code
|
|
* @param action the action that handles the array
|
|
* @throws NullPointerException if action is null
|
|
*/
|
|
public default void elements(Consumer<KEY_TYPE[]> action) {
|
|
#if TYPE_OBJECT
|
|
if(!isCastable()) return;
|
|
#endif
|
|
Objects.requireNonNull(action);
|
|
action.accept(elements());
|
|
}
|
|
}
|