Example usage for java.util LinkedList offerFirst

List of usage examples for java.util LinkedList offerFirst

Introduction

In this page you can find the example usage for java.util LinkedList offerFirst.

Prototype

public boolean offerFirst(E e) 

Source Link

Document

Inserts the specified element at the front of this list.

Usage

From source file:uk.ac.ebi.ep.base.search.EnzymeFinder.java

private List<UniprotEntry> computeUniqueEnzymes(List<UniprotEntry> enzymes, String keyword) {
    LinkedList<UniprotEntry> enzymeList = new LinkedList<>();
    LinkedList<UniprotEntry> theEnzymes = new LinkedList<>();
    //Deque<UniprotEntry> enzymeList = new LinkedList<>();
    Set<String> proteinNames = new HashSet<>();
    for (UniprotEntry entry : enzymes) {

        if (!proteinNames.contains(entry.getProteinName())) {

            String enzymeName = HtmlUtility.cleanText(entry.getProteinName()).toLowerCase();
            if (enzymeName.toLowerCase().matches(".*" + keyword.toLowerCase() + ".*")
                    && entry.getEntryType() != 1) {

                enzymeList.offerFirst(entry);

            } else {

                enzymeList.offerLast(entry);

            }//from  w w w  .ja  v  a  2 s .c o m

        }

        proteinNames.add(entry.getProteinName());

        computeFilterFacets(entry);

    }

    for (UniprotEntry enzyme : enzymeList) {
        if (HtmlUtility.cleanText(enzyme.getProteinName()).toLowerCase().equalsIgnoreCase(keyword.toLowerCase())
                && enzyme.getEntryType() != 1) {

            LOGGER.info("FOUND A MATCH " + enzyme.getProteinName() + " => " + keyword + " entry type "
                    + enzyme.getEntryType());
            theEnzymes.offerFirst(enzyme);

        } else {
            theEnzymes.offerLast(enzyme);

        }
    }

    return theEnzymes.stream().distinct().collect(Collectors.toList());
}