Class Utils

  • All Implemented Interfaces:

    
    public final class Utils
    
                        
    • Constructor Detail

    • Method Detail

      • mapToArray

         final static <T extends Any, R extends Any> Array<R> mapToArray(Array<T> $self, Function1<T, R> transform)

        Perform the given transform on every element in this array, and return a new array with the results.

        Equivalent to this.map { transform(it) }.toTypedArray(), but saves on the creation of an intermediate list.

      • mapToArray

         final static <T extends Any, R extends Any> Array<R> mapToArray(Collection<T> $self, Function1<T, R> transform)

        Perform the given transform on every element in this list, and return a new array with the results.

        Equivalent to this.map { transform(it) }.toTypedArray(), but saves on the creation of an intermediate list.

      • mapToArray

         final static <K extends Any, V extends Any, R extends Any> Array<R> mapToArray(Map<K, V> $self, Function1<Entry.Map<K, V>, R> transform)

        Perform the given transform on every element in this map, and return a new array with the results.

        Equivalent to this.map { transform(it) }.toTypedArray(), but saves on the creation of an intermediate list.

      • gcd

         final static Integer gcd(Integer $self, Integer b)

        Calculate the greatest common denominator of two integers.

        Since:

        0.18.4

      • getByName

         final static <E extends Enum<E>> E getByName(EnumEntries<E> $self, String name, Boolean ignoreCase)

        Get an enum constant by its name, or null if name is null; or does not match any of this enum's constants.

      • cl0

         final static Float cl0(Float a, Float b)

        Returns the value closer to zero.

        If either value is NaN, then the result is NaN.

        If a == b, then the result is a.

      • cl1

         final static Float cl1(Float a, Float b)

        Returns the value closer to one.

        If either value is NaN, then the result is NaN.

        If a == b, then the result is a.

      • min3

         final static Integer min3(Integer a, Integer b, Integer c)

        Returns the minimum value among three given ints.

        Parameters:
        a - the first value
        b - the second value
        c - the third value
        Returns:

        the minimum value among a, b, and c

      • radii

         final static FloatArray radii(Number $self)

        convert the given float into an array of 4 floats for radii.

      • stdout

         final static <T extends Any> T stdout(T $self, Object arg)

        print the object to stdout, then return it.

      • moveElement

         final static <E extends Any> Unit moveElement(Array<E> $self, Integer from, Integer to)

        Moves the given element from the from index to the to index.

        Note: this method makes absolutely no attempt to verify if the given indices are valid.

        Parameters:
        from - the index of the element to move
        to - the index to move the element to
      • ensureSize

         final static <T extends Any> List<T> ensureSize(List<T> $self, Integer size, Function1<Integer, T> initializer)

        Ensure that this list is at least size elements long, and if it is not, add elements to it using the given initializer.

        Since:

        1.0.7

      • ref

         final static <T extends Any> Ref.ObjectRef<T> ref(T $self)

        Box the given value into a Ref.ObjectRef.

      • deref

         final static <T extends Any> T deref(Ref.ObjectRef<T> $self)

        Return the value of this Ref.ObjectRef.

      • maybeRemove

         final static <K extends Any, V extends Any> V maybeRemove(Map<K, V> $self, K key, Boolean shouldRemove)

        Returns the value of the given key in the map, and if shouldRemove is true the value is also removed from the map.

        Since:

        1.0.2

      • both

         final static <T extends Any> Unit both(Pair<T, T> $self, Function1<T, Unit> func)

        Perform the given function on both elements of this pair. The highest common type of both elements is used as the type of the parameter.