com.github.TKnudsen.ComplexDataObject.data.ranking.RankingLinkedList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of complex-data-object Show documentation
Show all versions of complex-data-object Show documentation
A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.
package com.github.TKnudsen.ComplexDataObject.data.ranking;
import java.util.LinkedList;
/**
*
* Title: RankingLinkedList
*
*
*
* Description: structures objects in sorted manner. Based on a
* {@link LinkedList}.
*
*
*
* Copyright: Copyright (c) 2011-2015
*
*
* @author Juergen Bernard
* @version 1.03
*/
public class RankingLinkedList> extends LinkedList {
/**
*
*/
private static final long serialVersionUID = -3625638957983883603L;
public boolean add(T t) {
for (int i = 0; i < this.size(); i++) {
if (t.compareTo(get(i)) < 0) {
this.add(i, t);
return true;
}
}
super.add(t);
return true;
}
}