Example usage for java.util LinkedList addFirst

List of usage examples for java.util LinkedList addFirst

Introduction

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

Prototype

public void addFirst(E e) 

Source Link

Document

Inserts the specified element at the beginning of this list.

Usage

From source file:com.googlecode.psiprobe.controllers.logs.FollowController.java

protected ModelAndView handleLogFile(HttpServletRequest request, HttpServletResponse response,
        LogDestination logDest) throws Exception {

    ModelAndView mv = new ModelAndView(getViewName());
    File file = logDest.getFile();

    if (file.exists()) {
        LinkedList lines = new LinkedList();
        long actualLength = file.length();
        long lastKnownLength = ServletRequestUtils.getLongParameter(request, "lastKnownLength", 0);
        long currentLength = ServletRequestUtils.getLongParameter(request, "currentLength", actualLength);
        long maxReadLines = ServletRequestUtils.getLongParameter(request, "maxReadLines", 0);

        if (lastKnownLength > currentLength || lastKnownLength > actualLength || currentLength > actualLength) {
            ////from w w w  .  j  a va  2  s.  c  o  m
            // file length got reset
            //
            lastKnownLength = 0;
            lines.add(" ------------- THE FILE HAS BEEN TRUNCATED --------------");
        }

        BackwardsFileStream bfs = new BackwardsFileStream(file, currentLength);
        try {
            BackwardsLineReader br = new BackwardsLineReader(bfs);
            long readSize = 0;
            long totalReadSize = currentLength - lastKnownLength;
            String s;
            while (readSize < totalReadSize && (s = br.readLine()) != null) {
                if (!s.equals("")) {
                    lines.addFirst(s);
                    readSize += s.length();
                } else {
                    readSize++;
                }
                if (maxReadLines != 0 && lines.size() >= maxReadLines) {
                    break;
                }
            }

            if (lastKnownLength != 0 && readSize > totalReadSize) {
                lines.removeFirst();
            }
        } finally {
            bfs.close();
        }

        mv.addObject("lines", lines);
    }
    return mv;
}

From source file:org.squashtest.tm.service.internal.repository.hibernate.TestCaseDaoImpl.java

/**
 * @param userSorting//from  www.  j  a va2  s . c  om
 * @return
 */
/*
 * Issue #1629
 *
 * Observed problem : test cases sorted by references are indeed sorted by reference, but no more by name. Actual
 * problem : We always want them to be sorted by reference and name, even when we want primarily sort them by
 * project or execution type or else. Solution : The resultset will be sorted on all the attributes (ascending), and
 * the Sorting specified by the user will have an higher priority.
 *
 * See #createEffectiveSorting(Sorting sorting), just below
 */

private List<Sorting> createEffectiveSorting(Sorting userSorting) {

    LinkedList<Sorting> sortings = new LinkedList<Sorting>(defaultVerifiedTcSorting);

    // from that list we filter out the redundant element, considering the argument.
    // note that the sorting order is irrelevant here.
    ListIterator<Sorting> iterator = sortings.listIterator();
    while (iterator.hasNext()) {
        Sorting defaultSorting = iterator.next();
        if (defaultSorting.getSortedAttribute().equals(userSorting.getSortedAttribute())) {
            iterator.remove();
            break;
        }
    }

    // now we can set the Sorting specified by the user in first position
    sortings.addFirst(userSorting);

    return sortings;
}

From source file:org.sleeksnap.ScreenSnapper.java

/**
 * Register an upload filter// w  w  w  .j a  va 2s. c  om
 * 
 * @param filter
 *            The filter to register
 */
public void registerFilter(final UploadFilter<?> filter) {
    final Class<? extends Upload> type = getFilterType(filter);
    LinkedList<UploadFilter<?>> filterList = filters.get(type);
    if (filterList == null) {
        filters.put(type, filterList = new LinkedList<UploadFilter<?>>());
    }
    filterList.addFirst(filter);
}

From source file:org.dllearner.cli.DocumentationGenerator.java

public String getConfigDocumentationString() {
    String doc = "";
    doc += "This file contains an automatically generated files of all components and their config options.\n\n";

    Set<Class<?>> componentsDone = new HashSet<>();
    Class<?>[] nonComponentClasses = { CLI.class, GlobalDoc.class };

    // go through all types of components and write down their documentation
    List<Class> coreComps = Arrays.asList(AnnComponentManager.coreComponentClasses);
    Collections.reverse(coreComps);
    LinkedList<String> cc = new LinkedList<>();
    doc += "*************************\n" + "* Non-component classes *\n" + "*************************\n\n";
    for (Class<?> comp : nonComponentClasses) {
        if (componentsDone.contains(comp))
            continue;
        doc += getComponentConfigString(comp, Class.class);
        componentsDone.add(comp);/*w w w  .j  av  a2  s .  c o m*/
    }

    for (Class<?> cats : coreComps) {
        ComponentAnn ann = cats.getAnnotation(ComponentAnn.class);
        String name = cats.getSimpleName();
        if (ann != null) {
            name = ann.name();
        }
        StringBuilder sc = new StringBuilder();
        sc.append("\n" + Strings.repeat("*", name.length() + 4) + "\n" + "* " + name + " *\n"
                + Strings.repeat("*", name.length() + 4) + "\n\n");

        for (Class<? extends Component> comp : cm.getComponentsOfType(cats)) {
            if (componentsDone.contains(comp))
                continue;
            sc.append(getComponentConfigString(comp, cats));
            componentsDone.add(comp);
        }
        cc.addFirst(sc.toString());
    }
    doc += StringUtils.join(cc, "\n");
    for (Class<?> comp : cm.getComponents()) {
        StringBuilder sc = new StringBuilder();
        if (!componentsDone.contains(comp)) {
            if (componentsDone.contains(comp))
                continue;
            sc.append(getComponentConfigString(comp, Component.class));
            componentsDone.add(comp);
        }
        if (sc.length() != 0) {
            doc += "\n********************\n" + "* Other Components *\n" + "********************\n\n"
                    + sc.toString();
        }
    }

    return doc;
}

From source file:jext2.DataBlockAccess.java

/** Get up to maxBlocks BlockNrs for the logical fileBlockNr. I dont really like to change behavior
 * by specifing a flag variable but this is more or less like the linux implementation. Use getBlocks
 * or getBlocksAllocate./*from ww w. j a  v a2  s.co m*/
 * @param inode    Inode of the data block
 * @param fileBlockNr  the logical block address
 * @param maxBlocks    maximum blocks returned
 * @param create       true: create blocks if nesseccary; false: just read
 * @return             list of block nrs; if create=false null is returned if block does not exist
 * @throws NoSpaceLeftOnDevice
 * @throws FileTooLarge
 * @throws IOException
 */
@MustReturnLock
private LinkedList<Long> getBlocks(long fileBlockNr, long maxBlocks, boolean create)
        throws JExt2Exception, NoSpaceLeftOnDevice, FileTooLarge {

    if (fileBlockNr < 0 || maxBlocks < 1)
        throw new IllegalArgumentException();

    LinkedList<Long> result = new LinkedList<Long>();
    int[] offsets;
    long[] blockNrs;
    int depth;
    int existDepth;

    hierarchyLock.readLock().lock();

    offsets = blockToPath(fileBlockNr);
    depth = offsets.length;

    blockNrs = getBranch(offsets);
    existDepth = blockNrs.length;

    /* Simplest case - block found, no allocation needed */
    if (depth == existDepth) {
        long firstBlockNr = blockNrs[depth - 1];
        result.addFirst(firstBlockNr);

        long blocksToBoundary = 0;
        if (depth >= 2) /* indirect blocks */
            blocksToBoundary = superblock.getAddressesPerBlock() - offsets[depth - 1] - 1;
        else /* direct blocks */
            blocksToBoundary = Constants.EXT2_NDIR_BLOCKS - offsets[0] - 1;

        int count = 1;
        while (count < maxBlocks && count <= blocksToBoundary) {

            long nextByNumber = firstBlockNr + count;
            long nextOnDisk = -1;
            if (depth >= 2) /* indirect blocks */
                nextOnDisk = blocks.readBlockNumberFromBlock(blockNrs[depth - 2], offsets[depth - 1] + count);
            else /* direct blocks */
                nextOnDisk = inode.getBlock()[offsets[0] + count];

            /* check if next neighbor block belongs to inode */
            if (nextByNumber == nextOnDisk) {
                result.addLast(nextByNumber);
                count++;
            } else {
                break;
            }
        }
        assert hierarchyLock.getReadHoldCount() == 1 : "Returning without holding lock";
        return result;
    }

    assert hierarchyLock.getReadHoldCount() == 1 : "Should have a read lock around";

    /* Next simple case - plain lookup mode */
    if (!create) {
        assert hierarchyLock.getReadHoldCount() == 1 : "Returning without holding lock";
        return null;
    }

    hierarchyLock.readLock().unlock();

    /* Okay, we need to do block allocation. */
    hierarchyLock.writeLock().lock();
    long goal = findGoal(fileBlockNr, blockNrs, offsets);
    int count = depth - existDepth;

    LinkedList<Long> newBlockNrs = allocBranch(count, goal, offsets, blockNrs);
    spliceBranch(fileBlockNr, offsets, blockNrs, newBlockNrs);

    result.add(newBlockNrs.getLast());
    hierarchyLock.readLock().lock();
    hierarchyLock.writeLock().unlock();

    /* Again return with an open read lock */
    assert hierarchyLock.getReadHoldCount() == 1 : "Returning without holding lock";
    return result;
}

From source file:psiprobe.controllers.logs.FollowController.java

@Override
protected ModelAndView handleLogFile(HttpServletRequest request, HttpServletResponse response,
        LogDestination logDest) throws Exception {

    ModelAndView mv = new ModelAndView(getViewName());
    File file = logDest.getFile();

    if (file.exists()) {
        LinkedList<String> lines = new LinkedList<>();
        long actualLength = file.length();
        long lastKnownLength = ServletRequestUtils.getLongParameter(request, "lastKnownLength", 0);
        long currentLength = ServletRequestUtils.getLongParameter(request, "currentLength", actualLength);
        long maxReadLines = ServletRequestUtils.getLongParameter(request, "maxReadLines", 0);

        if (lastKnownLength > currentLength || lastKnownLength > actualLength || currentLength > actualLength) {

            // file length got reset
            lastKnownLength = 0;//from   w  w w .j a v  a  2 s  .  com
            lines.add(" ------------- THE FILE HAS BEEN TRUNCATED --------------");
        }

        try (BackwardsFileStream bfs = new BackwardsFileStream(file, currentLength)) {
            BackwardsLineReader br;
            if (logDest.getEncoding() != null) {
                br = new BackwardsLineReader(bfs, logDest.getEncoding());
            } else {
                br = new BackwardsLineReader(bfs);
            }
            long readSize = 0;
            long totalReadSize = currentLength - lastKnownLength;
            String line;
            while (readSize < totalReadSize && (line = br.readLine()) != null) {
                if (!line.isEmpty()) {
                    lines.addFirst(line);
                    readSize += line.length();
                } else {
                    readSize++;
                }
                if (maxReadLines != 0 && lines.size() >= maxReadLines) {
                    break;
                }
            }

            if (lastKnownLength != 0 && readSize > totalReadSize) {
                lines.removeFirst();
            }
        }

        mv.addObject("lines", lines);
    }
    return mv;
}

From source file:eulermind.MindDB.java

public List getInheritPath(Object dbId) {
    assert !(dbId instanceof Vertex);

    LinkedList inheritPath = new LinkedList();

    Object parentDbId = getParentDbId(dbId);
    while (parentDbId != null) {
        inheritPath.addFirst(parentDbId);
        parentDbId = getParentDbId(parentDbId);
    }//from ww w . j a va2  s . c om

    return inheritPath;
}

From source file:com.tencent.wstt.gt.activity.GTLogFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View logLayout = inflater.inflate(R.layout.gt_logactivity, container, false);
    displayWidth = DeviceUtils.getDisplayWidth(getActivity());

    rl_log_filter = (RelativeLayout) logLayout.findViewById(R.id.rl_log_filter);

    cb_logcatSwitch = (GTCheckBox) logLayout.findViewById(R.id.cb_logcat_switch);
    cb_logcatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override/*  w w w .j  av a  2 s .c om*/
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                // TODO logcat?
                logcatTask = new LogcatRunnable();
                new Thread(logcatTask).start();
            } else {
                logcatTask.killReader();
            }
        }
    });

    btn_delete = (ImageButton) logLayout.findViewById(R.id.gtlog_delete);
    btn_save = (ImageButton) logLayout.findViewById(R.id.gtlog_save);
    btn_open = (ImageButton) logLayout.findViewById(R.id.gtlog_open);

    btn_level_toast = (ImageButton) logLayout.findViewById(R.id.log_level_toast);
    btn_tag_toast = (ImageButton) logLayout.findViewById(R.id.log_tag_toast);

    /*
     * ??ImageView ??filterListViewfilterListView
     */
    img_empty = (ImageView) logLayout.findViewById(R.id.view_empty);
    img_empty.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            img_empty.setVisibility(View.GONE);
            filterListView.setVisibility(View.GONE);
            cancelFilterMsgInput(v);
            return false;
        }
    });

    /*
     * ?
     */
    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.gt_dailog_save, null, false);
    ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean);
    btn_cleanSavePath.setOnClickListener(this);

    et_savePath = (EditText) rl_save.findViewById(R.id.save_editor);
    String lastSaveLog = GTLogInternal.getLastSaveLog();
    if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.LOG_POSFIX)) {
        lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    }
    et_savePath.setText(lastSaveLog);
    dlg_save = new Builder(getActivity()).setTitle(getString(R.string.save_file)).setView(rl_save)
            .setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // ??
                    String path = et_savePath.getText().toString();
                    try {
                        File f = null;
                        if (FileUtil.isPathStringValid(path)) {
                            String validPath = FileUtil.convertValidFilePath(path, LogUtils.LOG_POSFIX);
                            if (FileUtil.isPath(validPath)) {
                                f = new File(validPath);
                                f.mkdirs();
                            } else {
                                f = new File(Env.ROOT_LOG_FOLDER, validPath);
                            }
                            GTLogInternal.setLastSaveLog(validPath);
                        }

                        if (f.exists()) {
                            f.delete();
                        }

                        LogUtils.writeLog(logAdapter.getUIEntryList(), f, false);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    dialog.dismiss();
                }

            }).create();

    btn_save.setOnClickListener(this);

    // 
    btn_delete.setOnClickListener(this);

    // 
    btn_open.setOnClickListener(this);

    // 
    rl_loglist = (RelativeLayout) logLayout.findViewById(R.id.rl_loglist);
    listView = (ListView) logLayout.findViewById(R.id.loglist);
    initCurLogAdapter();
    logAdapter.setFilter();
    listView.setAdapter(logAdapter);
    // button???
    listView.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            rl_log_filter.setVisibility(View.GONE);
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if (visibleItemCount + firstVisibleItem == totalItemCount) {
                logAdapter.setAutoRefresh(true);
            } else {
                logAdapter.setAutoRefresh(false);
            }
        }
    });
    // button?
    rl_loglist.setOnClickListener(this);
    listView.setOnTouchListener(logListTouchListener);

    // ?
    filterListView = (ListView) logLayout.findViewById(R.id.spinner_list);
    tagAdapter = new ArrayAdapter<String>(getActivity(), R.layout.gt_simple_dropdown_item);
    filterListView.setAdapter(tagAdapter);

    filterListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long arg3) {
            img_empty.setVisibility(View.GONE);
            filterListView.setVisibility(View.GONE);

            if (parent.getAdapter() == tagAdapter) {
                if (position == 0)
                    GTLogInternal.setCurFilterTag("");
                else
                    GTLogInternal.setCurFilterTag((String) parent.getAdapter().getItem(position));

                btn_tag.setText(tagAdapter.getItem(position));
            } else if (parent.getAdapter() instanceof MsgAdaptor) {
                String sCurSelectedMsg = (String) parent.getAdapter().getItem(position);
                LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList();
                LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory();

                GTLogInternal.setCurFilterMsg(sCurSelectedMsg);
                msgWatched = false;
                et_Msg.removeTextChangedListener(msg_watcher);
                String s = curShowDownMsgList.remove(position);

                curShowDownMsgList.addFirst(s);
                msgHistory.remove(s);
                msgHistory.addFirst(s);
                et_Msg.setText(sCurSelectedMsg);
                btn_msg_clear.setVisibility(View.VISIBLE);
                cancelFilterMsgInput(parent);
            } else {
                GTLogInternal.setCurFilterLevel(position);
                btn_level.setText(levelAdapter.getItem(position));
            }

            onLogChanged();
        }
    });

    // Activity???
    GTLogInternal.addLogListener(this);

    // ?

    //btn_search = (ImageButton) findViewById(R.id.log_search);

    btn_search = (ImageButton) logLayout.findViewById(R.id.gtlog_search);
    btn_search.setOnClickListener(this);

    // 
    btn_level = (Button) logLayout.findViewById(R.id.log_level);
    levelAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.log_level,
            R.layout.gt_simple_dropdown_item);
    btn_level.setText(levelAdapter.getItem(GTLogInternal.getCurFilterLevel()));

    btn_level.setOnClickListener(this);

    // TAG
    btn_tag = (Button) logLayout.findViewById(R.id.log_tag);
    if (GTLogInternal.getCurFilterTag().length() == 0) {
        btn_tag.setText("TAG");
    } else {
        btn_tag.setText(GTLogInternal.getCurFilterTag());
    }

    btn_tag.setOnClickListener(this);

    // 
    et_Msg = (EditText) logLayout.findViewById(R.id.log_msg);
    et_Msg.setText(GTLogInternal.getCurFilterMsg());

    et_Msg.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus && !logAdapter.isEmpty())// edit?
            {
                msgEtOnFocusOrClick();
            }
        }
    });

    et_Msg.setOnClickListener(this);

    et_Msg.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            switch (keyCode) {
            case KeyEvent.KEYCODE_ENTER:
                // ?showdown?
                msgWatched = false;
                et_Msg.removeTextChangedListener(msg_watcher);

                String word = et_Msg.getText().toString();
                if (!word.equals("")) {
                    LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList();
                    LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory();

                    msgHistory.remove(word);
                    msgHistory.addFirst(word);
                    curShowDownMsgList.remove(word);
                    curShowDownMsgList.addFirst(word);
                }

                filterListView.setVisibility(View.GONE);
                img_empty.setVisibility(View.GONE);

                cancelFilterMsgInput(v);

                return true;
            }
            return false;
        }
    });

    // ?
    btn_msg_clear = (ImageButton) logLayout.findViewById(R.id.log_msg_clear);
    btn_msg_clear.setOnClickListener(this);

    if (et_Msg.getText().toString().length() > 0) {
        btn_msg_clear.setVisibility(View.VISIBLE);
    } else {
        btn_msg_clear.setVisibility(View.GONE);
    }

    // ?
    btn_msg_input_cancel = (Button) logLayout.findViewById(R.id.log_msg_cancel);
    btn_msg_input_cancel.setOnClickListener(this);

    handler = new Handler();

    return logLayout;
}

From source file:de.anycook.db.mysql.DBMessage.java

public List<Message> getMessages(int sessionId, int lastId, int userId, int limit) throws SQLException {
    LinkedList<Message> messages = new LinkedList<>();
    PreparedStatement pStatement = connection.prepareStatement(
            "SELECT messages.id, sender, messages.text, datetime, nickname, users.image from messages "
                    + "LEFT JOIN users ON sender = users.id " + "WHERE message_sessions_id = ? "
                    + "AND messages.id > ? ORDER BY id DESC LIMIT ?");
    pStatement.setInt(1, sessionId);//from w  ww  . ja va2  s.  com
    pStatement.setInt(2, lastId);
    pStatement.setInt(3, limit);

    ResultSet data = pStatement.executeQuery();
    while (data.next()) {
        int id = data.getInt("messages.id");
        String text = data.getString("messages.text");
        Date datetime = DateParser.parseDateTime(data.getString("datetime"));
        boolean unread = isUnread(userId, sessionId, id);

        int senderId = data.getInt("sender");
        String senderName = data.getString("nickname");
        String senderImage = data.getString("users.image");
        User sender = new User(senderId, senderName, senderImage);

        Message message = new Message(id, sender, text, datetime, unread);
        messages.addFirst(message);
    }
    return messages;
}

From source file:uk.ac.ebi.intact.dataexchange.cvutils.model.CvObjectOntologyBuilder.java

/**
 * @param categories OboCategory could be PSI-MI slim, Drugable, etc.,
 * @return A subset of CvDagObjects if a category is passed, if not returns all
 *//*from  w  w  w .j a v  a  2 s  .  c  om*/
public List<CvDagObject> getAllCvs(OboCategory... categories) {

    List<CvDagObject> allCvs = new ArrayList<CvDagObject>();
    //until here
    List<CvObject> rootsAndChildren = new ArrayList<CvObject>();
    Collection<IdentifiedObject> rootOboObjects = getRootOBOObjects(categories);

    for (IdentifiedObject rootOboObject : rootOboObjects) {
        OBOObject rootObject = (OBOObject) rootOboObject;

        if (log.isTraceEnabled())
            log.trace("Adding Parent Object " + rootObject.getID());

        CvObject cvObjectRoot = toCvObject(rootObject, categories);

        rootsAndChildren.add(cvObjectRoot);
    }

    // handle the cvobjects with more than one parent here
    if (log.isDebugEnabled())
        log.debug("Roots and children size :" + rootsAndChildren.size());

    for (CvObject validCv : rootsAndChildren) {
        allCvs.addAll(itselfAndChildrenAsList((CvDagObject) validCv));
    }

    for (IdentifiedObject orphanObo : getOrphanOBOObjects()) {
        if (orphanObo instanceof OBOObject) {
            OBOObject orphanObj = (OBOObject) orphanObo;

            if (checkIfCategorySubset(orphanObj, categories)) {
                CvObject cvOrphan = toCvObject(orphanObj, categories);
                allCvs.addAll(itselfAndChildrenAsList((CvDagObject) cvOrphan));
            }
        }
    }

    allCvs = new ArrayList<CvDagObject>(new HashSet<CvDagObject>(allCvs));

    if (log.isDebugEnabled())
        log.debug("Size of the collection with all CVs: " + allCvs.size());

    // put identity in the first position, to avoid recursivity problems
    // put identity on top
    LinkedList<CvDagObject> orderedList = new LinkedList<CvDagObject>();
    for (CvDagObject cv : allCvs) {
        if (CvXrefQualifier.IDENTITY_MI_REF.equals(cv.getMiIdentifier())) {
            orderedList.addFirst(cv);
        } else {
            orderedList.add(cv);
        }
    }

    //Order by Putting CvXrefs first and CvDatabases next followed by all other topics
    return getAllOrderedCvs(orderedList);
}