Class CharSeq

    • Constructor Detail

      • CharSeq

        public CharSeq​(char[] characters)
        Create a new (distinct) CharSeq from the given characters. The given CharSequence is sorted and duplicate values are removed
        Parameters:
        characters - the characters.
        Throws:
        NullPointerException - if the characters are null.
        See Also:
        CharSeq(CharSequence)
      • CharSeq

        public CharSeq​(CharSequence characters)
        Create a new (distinct) CharSeq from the given characters. The given CharSequence is sorted and duplicate values are removed.
        Parameters:
        characters - the characters.
        Throws:
        NullPointerException - if the characters are null.
    • Method Detail

      • contains

        public boolean contains​(Object object)
        Description copied from interface: Seq
        Returns true if this sequence contains the specified element.
        Specified by:
        contains in interface Seq<Character>
        Parameters:
        object - element whose presence in this sequence is to be tested. The tested element can be null.
        Returns:
        true if this sequence contains the specified element
      • contains

        public boolean contains​(Character c)
        Test whether this character set contains the given character c.
        Parameters:
        c - the character to test.
        Returns:
        true if this character set contains the given character, false otherwise.
        Throws:
        NullPointerException - if the given character c is null.
      • contains

        public boolean contains​(char c)
        Test whether this character set contains the given character c.
        Parameters:
        c - the character to test.
        Returns:
        true if this character set contains the given character, false otherwise.
      • length

        public int length()
        Description copied from interface: BaseSeq
        Return the length of this sequence. Once the sequence is created, the length can't be changed.
        Specified by:
        length in interface BaseSeq<Character>
        Specified by:
        length in interface CharSequence
        Overrides:
        length in class ArraySeq<Character>
        Returns:
        the length of this sequence.
      • isEmpty

        public boolean isEmpty()
        Test whether this character set is empty.
        Specified by:
        isEmpty in interface BaseSeq<Character>
        Returns:
        true if this character set is empty, false otherwise.
      • hashCode

        public int hashCode()
        Description copied from interface: Seq
        Returns the hash code value for this sequence. The hash code is defined as followed:
        int hashCode = 1; final Iterator<E> it = seq.iterator(); while (it.hasNext()) { final E obj = it.next(); hashCode = 31*hashCode + (obj == null ? 0 : obj.hashCode()); }
        Specified by:
        hashCode in interface Seq<Character>
        Overrides:
        hashCode in class ArraySeq<Character>
        Returns:
        the hash code value for this list
        See Also:
        List.hashCode(), Seq.hashCode(BaseSeq)
      • equals

        public boolean equals​(Object obj)
        Description copied from interface: Seq
        Compares the specified object with this sequence for equality. Returns true if and only if the specified object is also a sequence, both sequence have the same size, and all corresponding pairs of elements in the two sequences are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) This definition ensures that the equals method works properly across different implementations of the Seq interface.
        Specified by:
        equals in interface Seq<Character>
        Overrides:
        equals in class ArraySeq<Character>
        Parameters:
        obj - the object to be compared for equality with this sequence.
        Returns:
        true if the specified object is equal to this sequence, false otherwise.
        See Also:
        List.equals(Object), Seq.equals(BaseSeq, Object)
      • expand

        public static String expand​(CharSequence pattern)
        Expands the character range for the given pattern. E.g a-zA-Z0-1 will return a string containing all upper and lower case characters (from a to z) and all digits form 0 to 9.
        Parameters:
        pattern - the pattern to expand.
        Returns:
        the expanded pattern.
        Throws:
        PatternSyntaxException - if the pattern could not be expanded.
        NullPointerException - if the pattern is null.
      • expand

        public static String expand​(char a,
                                    char b)
        Expands the characters between a and b.
        Parameters:
        a - the start character.
        b - the stop character.
        Returns:
        the expanded characters.
      • of

        public static CharSeq of​(CharSequence pattern)
        Expands the character range for the given pattern. E.g. a-zA-Z0-1 will return a string containing all upper and lower case characters (from a to z) and all digits form 0 to 9.
        Parameters:
        pattern - the pattern to expand.
        Returns:
        the expanded pattern.
        Throws:
        PatternSyntaxException - if the pattern could not be expanded.
        NullPointerException - if the pattern is null.
        See Also:
        expand(CharSequence)
      • of

        public static CharSeq of​(char a,
                                 char b)
        Expands the characters between a and b.
        Parameters:
        a - the start character.
        b - the stop character.
        Returns:
        the expanded characters.
        See Also:
        expand(char, char)
      • toISeq

        public static ISeq<CharactertoISeq​(CharSequence chars)
        Helper method for creating a sequence of characters from the given CharSequence. The returned sequence will contain all characters in the original order.
        Parameters:
        chars - the char sequence to convert.
        Returns:
        a sequence which will contain all given chars in the original order.