Changeset 177ef573 for router


Ignore:
Timestamp:
Aug 6, 2018 3:14:15 PM (2 years ago)
Author:
slumlord <slumlord@…>
Branches:
master
Children:
f97ec88
Parents:
fc22d0f
Message:

Update javadocs for CachedIteratorCollection?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/util/CachedIteratorCollection.java

    rfc22d0f r177ef573  
    1 // Extend `java.util.AbstractCollection` to create a collection that can be iterated over without creation of a new
    2 // object
    3 
    4 // https://docs.oracle.com/javase/7/docs/api/java/util/AbstractCollection.html
    5 
     1// The Node class below is derived from Java's LinkedList.java
    62/*
    73 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     
    2824 * questions.
    2925 */
    30 // The Node class below is from Java's LinkedList.java
    3126
    3227package net.i2p.router.util;
     
    3833import net.i2p.I2PAppContext;
    3934import net.i2p.util.Log;
     35
     36/**
     37 * Extend java.util.AbstractCollection to create a collection that can be
     38 * iterated over without creation of a new object
     39 *
     40 * @since 0.9.36
     41 *
     42 */
    4043
    4144public class CachedIteratorCollection<E> extends AbstractCollection<E> {
     
    6164        Node<E> prev;
    6265
    63         Node(Node<E> prev, E element, Node<E> next) {
     66        Node(Node<E> prev, E element) {
    6467            this.item = element;
    6568            this.prev = prev;
    66             this.next = next;
     69            this.next = null;
    6770        }
    6871    }
    6972
    7073    // First Node in the AbstractCollectionTest object
    71     private transient Node<E> first;
     74    private transient Node<E> first = null;
    7275
    7376    // Last Node in the AbstractCollectionTest object
    74     private transient Node<E> last;
     77    private transient Node<E> last = null;
    7578
    7679    /**
     
    8689    @Override
    8790    public boolean add(E element) {
     91        final Node<E> newNode = new Node<>(null, element);
    8892        if (this.size == 0) {
    89             final Node<E> newNode = new Node<>(null, element, null);
    9093            this.first = newNode;
    9194            this.last = newNode;
    9295        } else {
    93             final Node<E> newLast = new Node<>(this.last, element, null);
    94             this.last.next = newLast;
    95             this.last = newLast;
     96            this.last.next = newNode;
     97            this.last = newNode;
    9698        }
    9799        this.size++;
     
    206208     * Return size of current LinkedListTest object
    207209     */
    208     public int size() { return this.size; }
     210    public int size() {
     211        return this.size;
     212    }
    209213}
Note: See TracChangeset for help on using the changeset viewer.