Search in sources :

Example 36 with SortedSet

use of java.util.SortedSet in project groovy by apache.

the class StructuredSyntaxDocumentFilter method parseDocument.

/**
     * Parse the Document to update the character styles given an initial start
     * position.  Called by the filter after it has updated the text. 
     *
     * @param offset
     * @param length
     * @throws BadLocationException
     */
protected void parseDocument(int offset, int length) throws BadLocationException {
    // initialize the segment with the complete document so the segment doesn't
    // have an underlying gap in the buffer
    styledDocument.getText(0, styledDocument.getLength(), segment);
    buffer = CharBuffer.wrap(segment.array).asReadOnlyBuffer();
    // initialize the lexer if necessary
    if (!lexer.isInitialized()) {
        // prime the parser and reparse whole document
        lexer.initialize();
        offset = 0;
        length = styledDocument.getLength();
    } else {
        int end = offset + length;
        offset = calcBeginParse(offset);
        length = calcEndParse(end) - offset;
        // clean the tree by ensuring multi line styles are reset in area
        // of parsing
        SortedSet set = mlTextRunSet.subSet(Integer.valueOf(offset), Integer.valueOf(offset + length));
        if (set != null) {
            set.clear();
        }
    }
    // parse the document
    lexer.parse(buffer, offset, length);
}
Also used : SortedSet(java.util.SortedSet)

Example 37 with SortedSet

use of java.util.SortedSet in project groovy by apache.

the class StructuredSyntaxDocumentFilter method getMultiLineRun.

// given an offset, return the mlr it resides in
private MultiLineRun getMultiLineRun(int offset) {
    MultiLineRun ml = null;
    if (offset > 0) {
        Integer os = Integer.valueOf(offset);
        SortedSet set = mlTextRunSet.headSet(os);
        if (!set.isEmpty()) {
            ml = (MultiLineRun) set.last();
            ml = ml.end() >= offset ? ml : null;
        }
    }
    return ml;
}
Also used : SortedSet(java.util.SortedSet)

Example 38 with SortedSet

use of java.util.SortedSet in project robovm by robovm.

the class OldTreeSetTest method test_headSetLjava_lang_Object.

public void test_headSetLjava_lang_Object() {
    // Test for method java.util.SortedSet
    // java.util.TreeSet.headSet(java.lang.Object)
    Set s = ts.headSet(new Integer(100));
    assertEquals("Returned set of incorrect size", 100, s.size());
    for (int i = 0; i < 100; i++) assertTrue("Returned incorrect set", s.contains(objArray[i]));
    SortedSet sort = ts.headSet(new Integer(100));
    try {
        sort.headSet(new Integer(101));
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        ts.headSet(this);
        fail("ClassCastException expected");
    } catch (ClassCastException e) {
    //expected
    }
    try {
        ts.headSet(null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    //expected
    }
}
Also used : SortedSet(java.util.SortedSet) Set(java.util.Set) TreeSet(java.util.TreeSet) SortedSet(java.util.SortedSet)

Example 39 with SortedSet

use of java.util.SortedSet in project robovm by robovm.

the class OldTreeSetTest method test_subSetLjava_lang_ObjectLjava_lang_Object.

public void test_subSetLjava_lang_ObjectLjava_lang_Object() {
    // Test for method java.util.SortedSet
    // java.util.TreeSet.subSet(java.lang.Object, java.lang.Object)
    final int startPos = objArray.length / 4;
    final int endPos = 3 * objArray.length / 4;
    SortedSet aSubSet = ts.subSet(objArray[startPos], objArray[endPos]);
    assertTrue("Subset has wrong number of elements", aSubSet.size() == (endPos - startPos));
    for (int counter = startPos; counter < endPos; counter++) assertTrue("Subset does not contain all the elements it should", aSubSet.contains(objArray[counter]));
    try {
        ts.subSet(objArray[3], objArray[0]);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        ts.subSet(null, objArray[3]);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    //expected
    }
    try {
        ts.subSet(objArray[3], null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    //expected
    }
    try {
        ts.subSet(objArray[3], this);
        fail("ClassCastException expected");
    } catch (ClassCastException e) {
    //expected
    }
}
Also used : SortedSet(java.util.SortedSet)

Example 40 with SortedSet

use of java.util.SortedSet in project robovm by robovm.

the class OldTreeSetTest method test_tailSetLjava_lang_Object.

public void test_tailSetLjava_lang_Object() {
    // Test for method java.util.SortedSet
    // java.util.TreeSet.tailSet(java.lang.Object)
    Set s = ts.tailSet(new Integer(900));
    assertEquals("Returned set of incorrect size", 100, s.size());
    for (int i = 900; i < objArray.length; i++) assertTrue("Returned incorrect set", s.contains(objArray[i]));
    SortedSet sort = ts.tailSet(new Integer(101));
    try {
        sort.tailSet(new Integer(100));
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
    try {
        ts.tailSet(this);
        fail("ClassCastException expected");
    } catch (ClassCastException e) {
    //expected
    }
    try {
        ts.tailSet(null);
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    //expected
    }
}
Also used : SortedSet(java.util.SortedSet) Set(java.util.Set) TreeSet(java.util.TreeSet) SortedSet(java.util.SortedSet)

Aggregations

SortedSet (java.util.SortedSet)377 TreeSet (java.util.TreeSet)174 Iterator (java.util.Iterator)116 HashMap (java.util.HashMap)94 Map (java.util.Map)94 Set (java.util.Set)90 ArrayList (java.util.ArrayList)78 List (java.util.List)78 TreeMap (java.util.TreeMap)61 HashSet (java.util.HashSet)60 IOException (java.io.IOException)58 NavigableSet (java.util.NavigableSet)56 Test (org.junit.Test)50 Collectors (java.util.stream.Collectors)35 Collections (java.util.Collections)34 SortedMap (java.util.SortedMap)31 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)30 Comparator (java.util.Comparator)30 File (java.io.File)28 Collection (java.util.Collection)28