Example usage for java.util LinkedList removeFirstOccurrence

List of usage examples for java.util LinkedList removeFirstOccurrence

Introduction

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

Prototype

public boolean removeFirstOccurrence(Object o) 

Source Link

Document

Removes the first occurrence of the specified element in this list (when traversing the list from head to tail).

Usage

From source file:org.openmrs.module.kenyaemr.page.controller.chart.ChartViewPatientPageController.java

/**
 * Adds this patient to the user's recently viewed list
 * @param patient the patient//from  w  w  w.j av  a2 s. c o  m
 * @param session the session
 */
private void recentlyViewed(Patient patient, Session session) {
    String attrName = EmrConstants.APP_CHART + ".recentlyViewedPatients";

    LinkedList<Integer> recent = session.getAttribute(attrName, LinkedList.class);
    if (recent == null) {
        recent = new LinkedList<Integer>();
        session.setAttribute(attrName, recent);
    }
    recent.removeFirstOccurrence(patient.getPatientId());
    recent.add(0, patient.getPatientId());
    while (recent.size() > 10)
        recent.removeLast();
}

From source file:org.openmrs.module.kenyaemr.page.controller.MedicalChartViewPatientPageController.java

/**
  * Remember that this patient was just viewed
  *///  w w w.  j a v a 2  s  . c o m
private void recentlyViewed(Patient patient, Session session) {
    LinkedList<Integer> recent = session.getAttribute("kenyaemr.medicalChart.recentlyViewedPatients",
            LinkedList.class);
    if (recent == null) {
        recent = new LinkedList<Integer>();
        session.setAttribute("kenyaemr.medicalChart.recentlyViewedPatients", recent);
    }
    recent.removeFirstOccurrence(patient.getPatientId());
    recent.add(0, patient.getPatientId());
    while (recent.size() > 10)
        recent.removeLast();
}