Class OpPriorities


  • public class OpPriorities
    extends Object
    A tutorial showing how you can use Op priorities to implement Ops that take precedence over others in certain scenarios
    Author:
    Gabriel Selzer
    • Field Detail

      • iterableFunc

        public final Function<Iterable<Integer>,​String> iterableFunc
        An Op with default priority.
        Output parameters:
        Input parameters:
        n
        Implementation Note:
        op names="tutorial.priority"
      • listFunc

        public final Function<SortedSet<Integer>,​String> listFunc
        An Op with high priority.
        Output parameters:
        Input parameters:
        n
        Implementation Note:
        op names="tutorial.priority", priority="100.0"
    • Constructor Detail

      • OpPriorities

        public OpPriorities()
    • Method Detail

      • main

        public static void main​(String... args)
        Many algorithms are able to achieve performance improvements on a particular task by making some assumptions. For example, we might write a baseline "maximum" Op that works on java.lang.Iterable, which covers a lot of types, but we could do a lot better a TreeSet by using the SortedSet.last() method. Thus, we can write two different Ops, and get different outputs depending on whether the input is a SortedSet or something else.