Primitive-Collections/src/builder/resources/speiger/assets/collections/templates/sets/SortedSet.template

161 lines
5.5 KiB
Plaintext

package speiger.src.collections.PACKAGE.sets;
import java.util.SortedSet;
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
#if TYPE_OBJECT
import java.util.Comparator;
#else
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif
#if SETS_FEATURE
import speiger.src.collections.PACKAGE.utils.SETS;
#endif
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
/**
* A Type Specific SortedSet implementation to reduce boxing/unboxing
* with a couple extra methods that allow greater control over sets.
* @Type(T)
* @note ORDERED_SET is only extended until 0.6.0 for Compat reasons.
* The supported classes already implement ORDERED_SET directly and will remove SORTED_SET implementations in favor of ORDERED_SET instead
*/
public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, SortedSet<CLASS_TYPE>
{
/**
* A Type Specific Comparator method
* @return the type specific comparator
*/
@Override
public COMPARATOR KEY_GENERIC_TYPE comparator();
@Override
public SORTED_SET KEY_GENERIC_TYPE copy();
@Override
public BI_ITERATOR KEY_GENERIC_TYPE iterator();
/**
* A type Specific Iterator starting from a given key
* @param fromElement the element the iterator should start from
* @return a iterator starting from the given element
* @throws java.util.NoSuchElementException if fromElement isn't found
*/
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
#if SETS_FEATURE
/**
* Creates a Wrapped SortedSet that is Synchronized
* @return a new SortedSet that is synchronized
* @see SETS#synchronize
*/
public default SORTED_SET KEY_GENERIC_TYPE synchronize() { return SETS.synchronize(this); }
/**
* Creates a Wrapped SortedSet that is Synchronized
* @param mutex is the controller of the synchronization block
* @return a new SortedSet Wrapper that is synchronized
* @see SETS#synchronize
*/
public default SORTED_SET KEY_GENERIC_TYPE synchronize(Object mutex) { return SETS.synchronize(this, mutex); }
/**
* Creates a Wrapped SortedSet that is unmodifiable
* @return a new SortedSet Wrapper that is unmodifiable
* @see SETS#unmodifiable
*/
public default SORTED_SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
#endif
/**
* A Type Specific Type Splititerator to reduce boxing/unboxing
* @return type specific splititerator
*/
@Override
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
#if !TYPE_OBJECT
/**
* A Type Specific SubSet method to reduce boxing/unboxing
* @param fromElement where the SubSet should start
* @param toElement where the SubSet should end
* @return a SubSet that is within the range of the desired range
* @note Some implementations may not support this method.
* @note Some implementations may not keep the desired range when the original is changed.
*/
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement);
/**
* A Type Specific HeadSet method to reduce boxing/unboxing
* @param toElement where the HeadSet should end
* @return a HeadSet that is within the range of the desired range
* @note Some implementations may not support this method.
* @note Some implementations may not keep the desired range when the original is changed.
*/
public SORTED_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement);
/**
* A Type Specific TailSet method to reduce boxing/unboxing
* @param fromElement where the TailSet should start
* @return a TailSet that is within the range of the desired range
* @note Some implementations may not support this method.
* @note Some implementations may not keep the desired range when the original is changed.
*/
public SORTED_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement);
/**
* A method to get the first element in the set
* @return first element in the set
*/
public KEY_TYPE FIRST_KEY();
/**
* A method to get and remove the first element in the set
* @return first element in the set
*/
public KEY_TYPE POLL_FIRST_KEY();
/**
* A method to get the last element in the set
* @return last element in the set
*/
public KEY_TYPE LAST_KEY();
/**
* A method to get and remove the last element in the set
* @return last element in the set
*/
public KEY_TYPE POLL_LAST_KEY();
@Override
@Deprecated
public default SORTED_SET KEY_GENERIC_TYPE subSet(CLASS_TYPE fromElement, CLASS_TYPE toElement) { return subSet(OBJ_TO_KEY(fromElement), OBJ_TO_KEY(toElement)); }
@Override
@Deprecated
public default SORTED_SET KEY_GENERIC_TYPE headSet(CLASS_TYPE toElement) { return headSet(OBJ_TO_KEY(toElement)); }
@Override
@Deprecated
public default SORTED_SET KEY_GENERIC_TYPE tailSet(CLASS_TYPE fromElement) { return tailSet(OBJ_TO_KEY(fromElement)); }
@Override
@Deprecated
public default CLASS_TYPE first() { return KEY_TO_OBJ(FIRST_KEY()); }
@Override
@Deprecated
default CLASS_TYPE last() { return KEY_TO_OBJ(LAST_KEY()); }
#else
/**
* A method to get and remove the first element in the set
* @return first element in the set
*/
public CLASS_TYPE pollFirst();
/**
* A method to get and remove the last element in the set
* @return last element in the set
*/
public CLASS_TYPE pollLast();
@Override
public SORTED_SET KEY_GENERIC_TYPE subSet(CLASS_TYPE fromElement, CLASS_TYPE toElement);
@Override
public SORTED_SET KEY_GENERIC_TYPE headSet(CLASS_TYPE toElement);
@Override
public SORTED_SET KEY_GENERIC_TYPE tailSet(CLASS_TYPE fromElement);
#endif
}