javolution.util.internal.table.TableView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javolution-core-java-msftbx
Show all versions of javolution-core-java-msftbx
Only the Java Core part of Javolution library, with slight modifications for use in MSFTBX.
The newest version!
/*
* Javolution - Java(TM) Solution for Real-Time and Embedded Systems
* Copyright (C) 2012 - Javolution (http://javolution.org/)
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software is
* freely granted, provided that this notice is preserved.
*/
package javolution.util.internal.table;
import java.util.Collection;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import javolution.util.function.Equality;
import javolution.util.internal.collection.CollectionView;
import javolution.util.service.TableService;
/**
* Table view implementation; can be used as root class for implementations
* if target is {@code null}.
*/
public abstract class TableView extends CollectionView implements TableService {
private static final long serialVersionUID = 0x600L; // Version.
/**
* The view constructor or root class constructor if target is {@code null}.
*/
public TableView(TableService target) {
super(target);
}
@Override
public abstract void add(int index, E element);
@Override
public boolean addAll(int index, Collection extends E> c) {
return subList(index, index).addAll(c);
}
@Override
public void addFirst(E element) {
add(0, element);
}
@Override
public void addLast(E element) {
add(size(), element);
}
@Override
public abstract void clear();
@Override
public final boolean contains(Object o) {
return indexOf(o) >= 0;
}
@Override
public Iterator descendingIterator() {
return new ReversedTableImpl(this).iterator();
}
@Override
public final E element() {
return getFirst();
}
@Override
public abstract E get(int index);
@Override
public E getFirst() {
if (size() == 0) emptyError();
return get(0);
}
@Override
public E getLast() {
if (size() == 0) emptyError();
return get(size() - 1);
}
@SuppressWarnings("unchecked")
@Override
public int indexOf(Object o) {
Equality