Code example for ArrayDeque

Methods: addLastremoveFirstsize

0
    public void logManagingTrust(int userId, ComponentName agent, boolean managing) {
        addEvent(new Event(TYPE_MANAGING_TRUST, userId, agent, null, 0, false, managing));
    } 
 
    private void addEvent(Event e) {
        if (mEvents.size() >= HISTORY_LIMIT) {
            mEvents.removeFirst();
        } 
        mEvents.addLast(e);
    } 
 
    public void dump(PrintWriter writer, int limit, int userId, String linePrefix,
            boolean duplicateSimpleNames) {
        int count = 0;
        Iterator<Event> iter = mEvents.descendingIterator();
        while (iter.hasNext() && count < limit) {
            Event ev = iter.next();
            if (userId != UserHandle.USER_ALL && userId != ev.userId) {
                continue; 
            }