EntityList

public class EntityList<E extends Entity<?>> implements List<E>

Represents an immutable and synchronised list of AMPL entities. It can be obtained using the functions AMPL.getVariables, AMPL.getConstraints, AMPL.getSets, AMPL.getObjectives, AMPL.getParameters.

The collection cannot be modified by the user (entities cannot be added nor deleted) and is linked to an AMPL object. When the corresponding AMPL entities are modified (through AMPL.eval or any other operation which influences the number of entities), the collection is automatically invalidated. It is updated lazily at the next access.

If the corresponding AMPL object is not running anymore, or it is null, an exception is thrown on all operations.

Methods

public boolean add(E e)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public void add(int index, E element)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public boolean addAll(Collection<? extends E> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public boolean addAll(int index, Collection<? extends E> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public void clear()

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public boolean contains(Object o)

Return true if the collection contains the element o

public boolean containsAll(Collection<?> c)

Return true if the collection contains all the items in c

public E get(String name)

Get an entity by name.

Parameters:
  • name – Name of the entity to get
Returns:

The corresponding ampl.Entity

public E get(int index)

Get the item at the specified index

public int indexOf(Object o)

Get the index of the specified object

public boolean isEmpty()

Return true if the collection is empty

public Iterator<E> iterator()

Get the iterator for the collection

public int lastIndexOf(Object o)

Get the last index of the object o

public ListIterator<E> listIterator()

Get the list iterator for the collection

public ListIterator<E> listIterator(int index)

Get the list iterator for the collection, starting at index

public boolean remove(Object o)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public E remove(int index)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public boolean removeAll(Collection<?> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public boolean retainAll(Collection<?> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public E set(int index, E element)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public int size()

Get the number of items in the collection

See also: java.util.List.size()

public List<E> subList(int fromIndex, int toIndex)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.
public Object[] toArray()

Return an array containing the elements in the collection. NOTE that the array will not be immutable and consistency with the underlying AMPL entities is not guaranteed.

public <T> T[] toArray(T[] a)

Return an array containing the elements in the collection. NOTE that the array will not be immutable and consistency with the underlying AMPL entities is not guaranteed.

public String toString()

Return a string representation of this list of entities