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.

Fields

ampl

AMPL ampl

Constructors

EntityList

EntityList(AMPL ampl, EntityType e)

Methods

add

public boolean add(E e)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

add

public void add(int index, E element)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

addAll

public boolean addAll(Collection<? extends E> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

addAll

public boolean addAll(int index, Collection<? extends E> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

clear

public void clear()

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

contains

public boolean contains(Object o)

Return true if the collection contains the element o

containsAll

public boolean containsAll(Collection<?> c)

Return true if the collection contains all the items in c

get

public E get(String name)

Get an entity by name.

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

The corresponding ampl.Entity

get

public E get(int index)

Get the item at the specified index

indexOf

public int indexOf(Object o)

Get the index of the specified object

isEmpty

public boolean isEmpty()

Return true if the collection is empty

iterator

public Iterator<E> iterator()

Get the iterator for the collection

lastIndexOf

public int lastIndexOf(Object o)

Get the last index of the object o

listIterator

public ListIterator<E> listIterator()

Get the list iterator for the collection

listIterator

public ListIterator<E> listIterator(int index)

Get the list iterator for the collection, starting at index

remove

public boolean remove(Object o)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

remove

public E remove(int index)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

removeAll

public boolean removeAll(Collection<?> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

retainAll

public boolean retainAll(Collection<?> c)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

set

public E set(int index, E element)

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

size

public int size()

Get the number of items in the collection

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

subList

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

Unsupported operation. Throws exception.

Throws:
  • UnsupportedOperationException.

toArray

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.

toArray

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.

toString

public String toString()

Return a string representation of this list of entities