Class GapLists


  • public class GapLists
    extends java.lang.Object
    Helper class offering various functionality:
    - create wrapper list objects wrapping primitive GapLists
    - methods interacting with CharSequence, Reader, InputStream
    - add methods explaining reason if fails with DuplicateKeyException
    • Constructor Detail

      • GapLists

        public GapLists()
    • Method Detail

      • addExplained

        public static <E,​EE extends E,​K> boolean addExplained​(Key1List<E,​K> list,
                                                                          EE add)
        Implementation of KeyListImpl.add(E) which adds an explanatory exception message why adding failed with a DuplicateKeyException.
      • addExplained

        public static <E,​EE extends E,​K1,​K2> boolean addExplained​(Key2List<E,​K1,​K2> list,
                                                                                    EE add)
        Implementation of KeyListImpl.add(E) which adds an explanatory exception message why adding failed with a DuplicateKeyException.
      • createWrapperList

        public static IList<?> createWrapperList​(java.lang.Class<?> type)
        Create a GapList wrapping a primitive GapList, e.g. an IntObjGapList wrapping an IntGapList.
        Parameters:
        type - primitive type for GapList
        Returns:
        created wrapping GapList
        Throws:
        java.lang.IllegalArgumentException - if no primitive type is specified
      • createWrapperList

        public static IList<?> createWrapperList​(java.lang.Class<?> type,
                                                 int capacity)
        Create a GapList wrapping a primitive GapList, e.g. an IntObjGapList wrapping an IntGapList.
        Parameters:
        type - primitive type for GapList
        capacity - initial capacity of created list
        Returns:
        created wrapping GapList
        Throws:
        java.lang.IllegalArgumentException - if no primitive type is specified
      • toGapList

        public static <T> java.util.stream.Collector<T,​?,​GapList<T>> toGapList()
        Return collector which collects the elements into a GapList.
        Returns:
        collector
      • toBigList

        public static <T> java.util.stream.Collector<T,​?,​BigList<T>> toBigList()
        Return collector which collects the elements into a BigList.
        Returns:
        collector
      • read

        public static int read​(java.io.InputStream istream,
                               org.magicwerk.brownies.collections.primitive.ByteGapList list,
                               int len)
                        throws java.io.IOException
        Read specified number of bytes from InputStream into ByteGapList.
        Parameters:
        istream - input stream (source)
        list - list (target)
        len - maximum number of bytes to read
        Returns:
        number of bytes read into the buffer, -1 if end of stream has been reached
        Throws:
        java.io.IOException
      • write

        public static void write​(java.io.OutputStream ostream,
                                 org.magicwerk.brownies.collections.primitive.ByteGapList list,
                                 int off,
                                 int len)
                          throws java.io.IOException
        Write specified number of bytes from ByteGapList into OutputStream.
        Parameters:
        ostream - output stream (target)
        list - list (source)
        off - offset of first byte to write
        len - number of bytes to write
        Throws:
        java.io.IOException
      • read

        public static int read​(java.io.Reader reader,
                               org.magicwerk.brownies.collections.primitive.CharGapList list,
                               int len)
                        throws java.io.IOException
        Read specified number of chars from Reader into CharGapList.
        Parameters:
        reader - reader (source)
        list - list (target)
        len - maximum number of bytes to read
        Returns:
        number of bytes read into the buffer, -1 if end of stream has been reached
        Throws:
        java.io.IOException
      • write

        public static void write​(java.io.Writer writer,
                                 org.magicwerk.brownies.collections.primitive.CharGapList list,
                                 int off,
                                 int len)
                          throws java.io.IOException
        Write specified number of chars from CharGapList into Writer.
        Parameters:
        writer - writer (target)
        list - list (source)
        off - offset of first char to write
        len - number of chars to write
        Throws:
        java.io.IOException
      • add

        public static void add​(java.lang.CharSequence str,
                               org.magicwerk.brownies.collections.primitive.CharGapList list,
                               int start,
                               int end)
        Add specified number of chars from CharSequence into CharGapList.
        Parameters:
        str - CharSequence (source)
        list - list (target)
        start - start position of characters to add in CharSequence
        end - end position of characters to add in CharSequence