All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dongliu.commons.collection.ExLinkedList Maven / Gradle / Ivy

The newest version!
package net.dongliu.commons.collection;

import java.util.Collection;
import java.util.LinkedList;

/**
 * Expanded linked list
 *
 * @author Liu Dong
 */
public class ExLinkedList extends LinkedList implements ExList {
    private static final long serialVersionUID = -296474324601260821L;

    public ExLinkedList() {
    }

    public ExLinkedList(Collection c) {
        super(c);
    }


    /**
     * Create mutable list
     */
    public static  ExLinkedList of(T value) {
        ExLinkedList list = new ExLinkedList<>();
        list.add(value);
        return list;
    }

    /**
     * Create mutable list
     */
    public static  ExLinkedList of(T value1, T value2) {
        ExLinkedList list = new ExLinkedList<>();
        list.add(value1);
        list.add(value2);
        return list;
    }

    /**
     * Create mutable list
     */
    public static  ExLinkedList of(T value1, T value2, T value3) {
        ExLinkedList list = new ExLinkedList<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        return list;
    }

    /**
     * Create mutable list
     */
    public static  ExLinkedList of(T value1, T value2, T value3, T value4) {
        ExLinkedList list = new ExLinkedList<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        return list;
    }

    /**
     * Create mutable list
     */
    public static  ExLinkedList of(T value1, T value2, T value3, T value4, T value5) {
        ExLinkedList list = new ExLinkedList<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        list.add(value5);
        return list;
    }

    /**
     * Create mutable list
     */
    public static  ExLinkedList of(T value1, T value2, T value3, T value4, T value5,
                                              T value6) {
        ExLinkedList list = new ExLinkedList<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        list.add(value5);
        list.add(value6);
        return list;
    }

    /**
     * Create mutable list
     */
    public static  ExLinkedList of(T value1, T value2, T value3, T value4, T value5,
                                              T value6, T value7) {
        ExLinkedList list = new ExLinkedList<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        list.add(value5);
        list.add(value6);
        list.add(value7);
        return list;
    }
    
    @SafeVarargs
    public static  ExLinkedList of(T... values) {
        ExLinkedList list = new ExLinkedList<>();
        list.addAll(values);
        return list;
    }

    @Override
    public ExList subList(int fromIndex, int toIndex) {
        return ExList.wrap(super.subList(fromIndex, toIndex));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy