Example usage for java.util TreeSet size

List of usage examples for java.util TreeSet size

Introduction

In this page you can find the example usage for java.util TreeSet size.

Prototype

public int size() 

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:com.miz.mizuu.AddNetworkFilesourceDialog.java

@SuppressLint("UseSparseArrays")
public void search(View v) {
    final ArrayList<FileSource> sources = new ArrayList<FileSource>();

    DbAdapterSources dbHelper = MizuuApplication.getSourcesAdapter();

    // Fetch all movie sources and add them to the array
    Cursor cursor = dbHelper.fetchAllSources();
    while (cursor.moveToNext()) {
        if (cursor.getInt(cursor.getColumnIndex(DbAdapterSources.KEY_FILESOURCE_TYPE)) == FileSource.SMB)
            sources.add(new FileSource(cursor.getLong(cursor.getColumnIndex(DbAdapterSources.KEY_ROWID)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_FILEPATH)),
                    cursor.getInt(cursor.getColumnIndex(DbAdapterSources.KEY_FILESOURCE_TYPE)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_USER)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_PASSWORD)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_DOMAIN)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterSources.KEY_TYPE))));
    }//from w w w  . j a va2s  .com

    cursor.close();

    TreeSet<String> uniqueSources = new TreeSet<String>();

    int count = sources.size();
    for (int i = 0; i < count; i++) {
        String temp = sources.get(i).getFilepath().replace("smb://", "");
        temp = temp.substring(0, temp.indexOf("/"));
        uniqueSources.add(temp);
    }

    final CharSequence[] items = new CharSequence[uniqueSources.size() + 1];

    count = 0;
    Iterator<String> it = uniqueSources.iterator();
    while (it.hasNext()) {
        items[count] = it.next();
        count++;
    }

    items[items.length - 1] = getString(R.string.scanForSources);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.browseSources));
    builder.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (which == (items.length - 1)) {
                Intent intent = new Intent();
                intent.setClass(getApplicationContext(), SearchForNetworkShares.class);
                startActivity(intent);
            } else {
                showUserDialog(items, which);
            }
        }
    });
    builder.show();
}

From source file:org.paxle.crawler.impl.SubCrawlerManager.java

public Collection<ISubCrawler> getSubCrawlers(String protocol) {
    if (protocol == null)
        return Collections.emptyList();
    protocol = protocol.trim().toLowerCase();

    final TreeSet<ServiceReference> refs = this.subCrawlerList.get(protocol);
    if (refs == null)
        return Collections.emptyList();

    final ArrayList<ISubCrawler> list = new ArrayList<ISubCrawler>(refs.size());
    for (final ServiceReference ref : refs) {
        if (this.isEnabled(protocol, ref)) {
            list.add((ISubCrawler) this.context.locateService(SERVICE_REFS_SUBCRAWLERS, ref));
        }/*  w ww.ja v  a2 s.c o m*/
    }

    return list;
}

From source file:org.openanzo.glitter.query.SPARQLAlgebra.java

/**
 * Implements the SPARQL LeftJoin operator. (For the SPARQL <tt>OPTIONAL</tt> keyword.)
 * /*from w w w .  j  a va 2  s .c  om*/
 * @param set1
 *            The left-hand-side of the outer join. See the SPARQL spec. for precise semantics.
 * @param set2
 *            The right-hand-side of the outer join.
 * @param filters
 *            Filters that are scoped to this left join.
 * @return The results of applying the LeftJoin operator.
 */
static public SolutionSet leftJoin(SolutionSet set1, SolutionSet set2, Set<Expression> filters) {
    Comparator<Value> comparator = getComparator(set1, set2);

    if (set1 == null)
        return filterSolutions(set2, filters);
    if (set2 == null)
        return filterSolutions(set1, filters);
    long start = 0;
    boolean isEnabled = RequestAnalysis.getAnalysisLogger().isDebugEnabled();
    if (isEnabled) {
        RequestAnalysis.getAnalysisLogger().debug(LogUtils.GLITTER_MARKER,
                "[glitter_SPARQLAlgebra_startLeftJoin] {}:{}", Integer.toString(set1.size()),
                Integer.toString(set2.size()));
        start = System.currentTimeMillis();
    }
    SolutionSet newSolutions = new CustomCompareSolutionSet.ComparableSolutionList(comparator);
    PatternSolution sol1[] = set1.toArray(new PatternSolution[0]);
    // count1 contains all the variables (& bnodes) in the first (required)
    // solution set. count2 contains all the bindables that appear in the
    // second.
    TreeSet<Bindable> count1 = new TreeSet<Bindable>();
    for (PatternSolution element : sol1) {
        for (Bindable bindable : element.getBoundDomain(true)) {
            count1.add(bindable);
        }
    }

    PatternSolution sol2[] = set2.toArray(new PatternSolution[0]);
    TreeSet<Bindable> count2 = new TreeSet<Bindable>();
    for (PatternSolution element : sol2) {
        for (Bindable bindable : element.getBoundDomain(true)) {
            count2.add(bindable);
        }
    }
    // populate matchSet with all the bindables that are in common
    // between the two solution sets.  Order the Binding names in the matchSet
    TreeSet<Bindable> matchSet = new TreeSet<Bindable>();
    if (count1.size() < count2.size()) {
        for (Bindable bindable : count1) {
            if (count2.contains(bindable))
                matchSet.add(bindable);
        }
    } else {
        for (Bindable bindable : count2) {
            if (count1.contains(bindable)) {
                matchSet.add(bindable);
            }
        }
    }
    Bindable matchedBindables[] = matchSet.toArray(new Bindable[0]);
    //Matt:Sort the solutions in sol1+sol2 based on the ordered matchSet, ie
    //the matchSet is sorted alphabetically by the binding names, so sort the solutions in sol1 + sol2
    //by a progressive alphabetical sort based on the ordered binding names, ie
    //if you have binding "A" and binding "B", the solutions would get ordered first by
    //and alphabetical sort of the Binding "A" values, and when the values of Binding "A" match,
    //alphabetical sort of Biding "B" values.
    //
    //Example:  2 Binding "A" and "B"
    //
    // row 1:  A=adam  B=zebra
    // row 2:  A=charlie b=apple
    // row 3:  A=adam  B=david
    // row 4:  A=zed   B=arrow

    //Sort order would be
    // row 3:  A=adam  B=david   //since adam is alphabetically lower than charlie and zed, and then david is lower than zebra
    // row 1:  A=adam  B=zebra
    // row 2:  A=charlie b=apple //charlie is after adam, and before zed, apple isn't used in sort since there are no other values with a match on A
    // row 4:  A=zed   B=arrow  //zed is after adam and charlie, arrow isn't used in sort since there are no other values with a match on A

    long startSort = 0;
    if (isEnabled) {
        startSort = System.currentTimeMillis();
    }
    Arrays.sort(sol1, 0, sol1.length, new PatternSolutionImpl.SetSolutionComparator(matchSet, comparator));
    if (isEnabled) {
        RequestAnalysis.getAnalysisLogger().debug(LogUtils.GLITTER_MARKER,
                "[glitter_SPARQLAlgebra_leftSortTime] {}",
                Long.toString(System.currentTimeMillis() - startSort));
        startSort = System.currentTimeMillis();
    }
    Arrays.sort(sol2, 0, sol2.length, new PatternSolutionImpl.SetSolutionComparator(matchSet, comparator));
    if (isEnabled) {
        RequestAnalysis.getAnalysisLogger().debug(LogUtils.GLITTER_MARKER,
                "[glitter_SPARQLAlgebra_rightSortTime] {}",
                Long.toString(System.currentTimeMillis() - startSort));
        startSort = System.currentTimeMillis();
    }
    // j is our current starting position for iterating over the optional
    // solutions. we can skip optional solutions p..r if we know that all
    // of them are incompatible with required solutions
    // //Matt:You know they are incompatiable because the sort order of the 2 solution sets is the same
    int j = 0;
    //long start = System.currentTimeMillis();

    for (PatternSolution solution1 : sol1) {
        Bindable sol1Bindables[] = solution1.getBoundDomainArray();
        boolean oneMatch = false;
        boolean done = false;
        //Matt:Since the solutions in the 2 sets are in the same sort order, you know that if
        //you compare solution(k) from the right solution set with solution(i) from the left solution set and solution(k) is
        //lower in the sort order than solution(i), then all the remaining solutions in left solution set will also have a
        //higher sort order than solutions(0-k) in right solution set.
        for (int k = j; k < sol2.length && !done; k++) {
            if (sol1Bindables.length == 0) {
                // the empty solution is the unit / identity solution
                oneMatch = true;
                newSolutions.add(sol2[k]);
            } else {
                // match starts as false; if all the bindings in solution1
                // match bindings in solution2 (i.e. solution1 is compatible
                // with solution2), then match==true.
                //
                // Lee: There seems to be a bug here if the intersection of
                // bindable1 and bindable2 is empty: in this case, solution1 does not get
                // extended by solution2, as it should be. Would this be fixed
                // by defaulting match to true?
                boolean match = true;
                boolean cloned = false;
                PatternSolution solution2 = sol2[k];
                // Map<Bindable, Value> conjunction = new HashMap<Bindable, Value>();
                Bindable bindables2[] = solution2.getBoundDomainArray();
                // we traverse the bindables in these solutions in parallel
                // this counter is our current starting position in the optional bindables
                //Matt:Since the bindables in the 2 arrays are in the same sort order, you know that if
                //you compare bindable(m) from the right array with bindable(l) from the left array and bindable(m) is
                //lower in the sort order than bindable(l), then all the remaining bindable in left array will also have a
                //higher sort order than bindable(0-m) in right array.
                int m = 0;
                // breaker is true if solution1 and solution2 are not compatible;
                // once one non-compatible binding has been found, the rest of
                // the bindables in solution1 will be copied, but we won't bother
                // checking them against solution2.
                boolean breaker = false;
                if (bindables2.length > 0) {
                    for (Bindable element : matchedBindables) {
                        // put in the required solution, unmodified, regardless of whether
                        // we've found any incompatibilities yet
                        //conjunction.put(element, solution1.getBinding(element));
                        for (int mm = m; mm < bindables2.length && !breaker; mm++) {
                            int comp1 = element.compareTo(bindables2[mm]);
                            if (comp1 == 0) {
                                // the same bindable is in both solutions, check
                                // the value its bound to; note that solutions in each
                                // solution set are ordered by comparing terms (bound
                                // values)
                                Value term1 = solution1.getBinding(element);
                                //If term is null, this means that lh solution does not have a binding for a shared binding, so have to do slow conjoin
                                if (term1 == null) {
                                    PatternSolution newSolution = conjoin(solution1, solution2);
                                    if (newSolution != null) {
                                        if (keepSolution(newSolution, filters)) {
                                            // oneMatch indicates that solution1 (from the left-hand side)
                                            // was compatible with at least one solution from the right-hand
                                            // solution set
                                            oneMatch = true;
                                            newSolutions.add(newSolution);
                                        }
                                    }
                                    match = false;
                                    breaker = true;
                                } else {
                                    Value term2 = solution2.getBinding(bindables2[mm]);
                                    int comp = comparator.compare(term1, term2);
                                    if (comp > 0) {
                                        // See note above - since the left solution has
                                        // a higher value for this term, we can skip all
                                        // right-hand solutions before this one when we
                                        // start with the next left-hand solution.
                                        match = false;
                                        breaker = true;
                                        j = k;
                                        break;
                                    } else if (comp < 0) {
                                        match = false;
                                        breaker = true;
                                        done = true;
                                        break;
                                    } else {
                                        if (!cloned) {
                                            bindables2 = bindables2.clone();
                                            cloned = true;
                                        }
                                        match = true;
                                        // conjunction.put(bindables2[mm], term);
                                        bindables2[mm] = null;
                                        m = mm + 1;
                                        break;
                                    }
                                }
                            } else if (comp1 > 0) {
                                m = mm;
                            }
                        }
                    }
                    // match is true if all of the terms in common between solution1
                    // and solution2 are bound to the same value in both solutions
                    if (match) {
                        PatternSolutionImpl newSolution = new PatternSolutionImpl(solution1);
                        // before we accept this conjoined solution, we need to make sure
                        // it passes the filter
                        for (Bindable element : bindables2) {
                            // bindings that match those in solution1 were nulled out above
                            // so if a binding is not null, it extends solution 1 and we copy
                            // it into the conjunction
                            if (element != null) {
                                newSolution.setBinding(element, solution2.getBinding(element));
                            }
                        }
                        if (keepSolution(newSolution, filters)) {
                            // oneMatch indicates that solution1 (from the left-hand side)
                            // was compatible with at least one solution from the right-hand
                            // solution set
                            oneMatch = true;
                            newSolutions.add(newSolution);
                        }
                    }
                }
            }
        }
        // if solution1 wasn't compatible with any solutions in the right-hand side, then we just
        // copy solution1 into our resultset untouched
        if (!oneMatch) {
            newSolutions.add(solution1);
        }
    }
    //System.err.println("LeftJoin:" + (System.currentTimeMillis() - start) + ":" + newSolutions.size());
    if (isEnabled) {
        RequestAnalysis.getAnalysisLogger().debug(LogUtils.GLITTER_MARKER,
                "[glitter_SPARQLAlgebra_endLeftJoin] {}:{}", Integer.toString(newSolutions.size()),
                Long.toString(System.currentTimeMillis() - start));
    }
    return newSolutions;
    /*if (set1 == null)
     return set2;
     if (set2 == null)
     return set1;
     SolutionSet newSolutions = new SolutionList();
     for (PatternSolution ps1 : set1) {
     boolean extendedPs1 = false;
     for (PatternSolution ps2 : set2) {
     PatternSolution psNew = ps1.conjoin(ps2);
     if (psNew != null) {
     extendedPs1 = true;
     newSolutions.add(psNew);
     }
     }
     // for this to be a left  outer join, we have to include the left-hand
     // pattern solution even if all of the right-hand solutions conflict
     // with it
     if (!extendedPs1)
     newSolutions.add(ps1);
     }
     return newSolutions;
     */
}

From source file:info.magnolia.test.mock.MockContentTest.java

/**
 * This is the mock-equivalent test of {@link info.magnolia.cms.core.DefaultContentTest#testNameFilteringWorksForBothBinaryAndNonBinaryProperties()}.
 *//*ww w. j  a  v  a2s .  c  o  m*/
@Test
public void testNameFilteringWorksForBothBinaryAndNonBinaryProperties() throws Exception {
    String contentProperties = StringUtils.join(Arrays.asList("/somepage/mypage@type=mgnl:content",
            "/somepage/mypage/paragraphs@type=mgnl:contentNode",
            "/somepage/mypage/paragraphs/0@type=mgnl:contentNode",
            "/somepage/mypage/paragraphs/0@type=mgnl:contentNode",

            // 2 regular props
            "/somepage/mypage/paragraphs/0/attention=booyah",
            "/somepage/mypage/paragraphs/0/imaginary=date:2009-10-14T08:59:01.227-04:00",

            // 3 binaries
            "/somepage/mypage/paragraphs/0/attachment1@type=mgnl:resource",
            "/somepage/mypage/paragraphs/0/attachment1.fileName=hello",
            "/somepage/mypage/paragraphs/0/attachment1.extension=gif",
            "/somepage/mypage/paragraphs/0/attachment1.jcr\\:data=X",
            "/somepage/mypage/paragraphs/0/attachment1.jcr\\:mimeType=image/gif",
            "/somepage/mypage/paragraphs/0/attachment1.jcr\\:lastModified=",

            "/somepage/mypage/paragraphs/0/attachment2@type=mgnl:resource",
            "/somepage/mypage/paragraphs/0/attachment2.fileName=test",
            "/somepage/mypage/paragraphs/0/attachment2.extension=jpeg",
            "/somepage/mypage/paragraphs/0/attachment2.jcr\\:data=X",
            "/somepage/mypage/paragraphs/0/attachment2.jcr\\:mimeType=image/jpeg",
            "/somepage/mypage/paragraphs/0/attachment2.jcr\\:lastModified=",

            "/somepage/mypage/paragraphs/0/image3@type=mgnl:resource",
            "/somepage/mypage/paragraphs/0/image3.fileName=third",
            "/somepage/mypage/paragraphs/0/image3.extension=png",
            "/somepage/mypage/paragraphs/0/image3.jcr\\:data=X",
            "/somepage/mypage/paragraphs/0/image3.jcr\\:mimeType=image/png",
            "/somepage/mypage/paragraphs/0/image3.jcr\\:lastModified=",

            // and more which should not match
            "/somepage/mypage/paragraphs/0/foo=bar", "/somepage/mypage/paragraphs/0/mybool=boolean:true",
            "/somepage/mypage/paragraphs/0/rand@type=mgnl:resource",
            "/somepage/mypage/paragraphs/0/rand.fileName=randdddd",
            "/somepage/mypage/paragraphs/0/rand.extension=png",
            "/somepage/mypage/paragraphs/0/rand.jcr\\:data=X",
            "/somepage/mypage/paragraphs/0/rand.jcr\\:mimeType=image/png",
            "/somepage/mypage/paragraphs/0/rand.jcr\\:lastModified="), "\n");
    // --- only this line differs from the DefaultContentTest equivalent
    final MockHierarchyManager hm = MockUtil.createHierarchyManager(contentProperties);
    // ---

    final Content content = hm.getContent("/somepage/mypage/paragraphs/0");
    final Collection<NodeData> props = content.getNodeDataCollection("att*|ima*");
    assertEquals(5, props.size());

    // sort by name
    final TreeSet<NodeData> sorted = new TreeSet<NodeData>(new Comparator<NodeData>() {
        @Override
        public int compare(NodeData o1, NodeData o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    sorted.addAll(props);
    // sanity check - just recheck we still have 5 elements
    assertEquals(5, sorted.size());
    final Iterator<NodeData> it = sorted.iterator();
    final NodeData a = it.next();
    final NodeData b = it.next();
    final NodeData c = it.next();
    final NodeData d = it.next();
    final NodeData e = it.next();
    assertEquals("attachment1", a.getName());
    assertEquals(PropertyType.BINARY, a.getType());
    assertEquals("attachment2", b.getName());
    assertEquals(PropertyType.BINARY, b.getType());
    assertEquals("image3", d.getName());
    assertEquals(PropertyType.BINARY, d.getType());
    assertEquals("image3", d.getName());
    assertEquals(PropertyType.BINARY, d.getType());

    assertEquals("attention", c.getName());
    assertEquals(PropertyType.STRING, c.getType());
    assertEquals("booyah", c.getString());
    assertEquals("imaginary", e.getName());
    assertEquals(PropertyType.DATE, e.getType());
    assertEquals(true, e.getDate().before(Calendar.getInstance()));
}

From source file:com.fileanalyzer.util.LineStatisticCalculator.java

public FileStatistic getFileStatistic() {
    FileStatistic fileStatis = new FileStatistic();

    fileStatis.setLengthLine(new Long(line.length()));
    String strArr[] = line.split(regexp);
    TreeSet<Integer> maxWord = new TreeSet();
    TreeSet<Integer> minWord = new TreeSet();
    long sumWords = 0;
    for (int i = 0; i < strArr.length; ++i) {
        int strSize = strArr[i].length();
        sumWords += strSize;/*  ww w. j ava2  s.c  o m*/
        if (i > 0 && i < strArr.length - 1)
            maxWord.add(strSize);
        minWord.add(strSize);
    }
    fileStatis.setLine(HtmlUtils.htmlEscape(line));
    if (sumWords > 0) {
        fileStatis.setAvgWord(new Double(sumWords / strArr.length));
        fileStatis.setMinWord(new Long(minWord.first()));
    }
    if (maxWord.size() > 0)
        fileStatis.setMaxWord(new Long(maxWord.last()));
    if (getIdFk() != null)
        fileStatis.setFileId(getIdFk());
    return fileStatis;
}

From source file:org.wso2.andes.kernel.slot.SlotManagerClusterMode.java

/**
 * {@inheritDoc}/*from  w w w  .  j  a va2s  .  c  o  m*/
 */
@Override
public long getSafeZoneLowerBoundId(String queueName) throws AndesException {
    long lowerBoundId = -1;
    String lockKey = queueName + SlotManagerClusterMode.class;
    synchronized (lockKey.intern()) {
        //get the upper bound messageID for each unassigned slots as a set for the specific queue
        TreeSet<Long> messageIDSet = slotAgent.getSlotBasedMessageIds(queueName);

        if (messageIDSet.size() >= safetySlotCount) {
            lowerBoundId = messageIDSet.toArray(new Long[messageIDSet.size()])[safetySlotCount - 1] + 1;
            // Inform the slot manager regarding the current expiry deletion range and queue
            setDeletionTaskState(queueName, lowerBoundId);
        }
    }
    return lowerBoundId;
}

From source file:org.apache.accumulo.core.client.mapreduce.lib.partition.RangePartitioner.java

private synchronized Text[] getCutPoints() throws IOException {
    if (cutPointArray == null) {
        String cutFileName = conf.get(CUTFILE_KEY);
        Path[] cf = DistributedCacheHelper.getLocalCacheFiles(conf);

        if (cf != null) {
            for (Path path : cf) {
                if (path.toUri().getPath().endsWith(cutFileName.substring(cutFileName.lastIndexOf('/')))) {
                    TreeSet<Text> cutPoints = new TreeSet<Text>();
                    Scanner in = new Scanner(new BufferedReader(
                            new InputStreamReader(new FileInputStream(path.toString()), Constants.UTF8)));
                    try {
                        while (in.hasNextLine())
                            cutPoints//from  w  ww .j a  va  2 s  . co  m
                                    .add(new Text(Base64.decodeBase64(in.nextLine().getBytes(Constants.UTF8))));
                    } finally {
                        in.close();
                    }
                    cutPointArray = cutPoints.toArray(new Text[cutPoints.size()]);
                    break;
                }
            }
        }
        if (cutPointArray == null)
            throw new FileNotFoundException(cutFileName + " not found in distributed cache");
    }
    return cutPointArray;
}

From source file:com.fileanalyzer.util.LineStatisticCalculator.java

public StringBuilder getSqlInsertFileStatistic() {
    Map<String, Object> params = new HashMap<>();
    StringBuilder sql = new StringBuilder("INSERT INTO " + FileStatistic.FileStatisticKey.TABLE + " ");
    params.put(FileStatisticKey.LENGTHLINE, new Long(line.length()));
    String strArr[] = line.split(regexp);
    TreeSet<Integer> maxWord = new TreeSet();
    TreeSet<Integer> minWord = new TreeSet();
    long sumWords = 0;
    for (int i = 0; i < strArr.length; ++i) {
        int strSize = strArr[i].length();
        sumWords += strSize;/* ww  w  .j  a v a 2  s.  c  om*/
        if (i > 0 && i < strArr.length - 1)
            maxWord.add(strSize);
        minWord.add(strSize);
    }
    params.put(FileStatisticKey.LINE, HtmlUtils.htmlEscape(line));
    if (sumWords > 0) {
        params.put(FileStatisticKey.AVGWORD, new Double(sumWords / strArr.length));
        params.put(FileStatisticKey.MINWORD, new Long(minWord.first()));
    }
    if (maxWord.size() > 0)
        params.put(FileStatisticKey.MAXWORD, new Long(new Long(maxWord.last())));
    if (getIdFk() != null)
        params.put(FileStatisticKey.FILEID, getIdFk());
    genParamAndValues(sql, params);

    return sql;
}

From source file:com.BibleQuote.BibleQuoteAndroid.ui.ReaderActivity.java

@Override
public void onReaderViewChange(ChangeCode code) {
    if (code == ChangeCode.onChangeReaderMode) {
        updateActivityMode();/*from w  w  w.java2s.co m*/
    } else if (code == ChangeCode.onUpdateText || code == ChangeCode.onScroll) {
        viewChapterNav();
    } else if (code == ChangeCode.onChangeSelection) {
        TreeSet<Integer> selVerses = vWeb.getSelectedVerses();
        if (selVerses.size() == 0) {
            if (currActionMode != null) {
                currActionMode.finish();
                currActionMode = null;
            }
        } else if (currActionMode == null) {
            currActionMode = startActionMode(new ActionSelectText());
        }
    } else if (code == ChangeCode.onLongPress) {
        viewChapterNav();
        if (vWeb.getMode() == ReaderWebView.Mode.Read)
            onChooseChapterClick();
    } else if (code == ChangeCode.onDoubleTap) {
        findInDictionaryInternal(vWeb.sWortForDict);
    } else if (code == ChangeCode.onUpNavigation) {
        vWeb.pageUp(false);
    } else if (code == ChangeCode.onDownNavigation) {
        vWeb.pageDown(false);
    } else if (code == ChangeCode.onLeftNavigation) {
        prevChapter();
    } else if (code == ChangeCode.onRightNavigation) {
        nextChapter();
    }
}

From source file:org.jactr.core.production.four.DefaultSubsymbolicProduction4.java

protected void setReferenceTimes(Collection<Number> times, IReferences references, String parameterName) {
    double[] oldTimes = references.getTimes();

    /*/*from w ww  .j av a2 s .  c o  m*/
     * we do not clear here since count may have been set and this reference
     * list may be optimized
     */

    TreeSet<Double> refTimes = new TreeSet<Double>();
    for (Number time : times)
        refTimes.add(time.doubleValue());

    /*
     * adjust the reference count so that it will be the same after we add these
     * references
     */
    references.setNumberOfReferences(Math.max(0, references.getNumberOfReferences() - refTimes.size()));

    for (Double time : refTimes)
        references.addReferenceTime(time);

    _lastFiringTime = Double.NEGATIVE_INFINITY;

    if (_parentProduction.hasListeners())
        _parentProduction.dispatch(
                new ProductionEvent(_parentProduction, parameterName, references.getTimes(), oldTimes));
}