org.cpsolver.ifs.assignment

## Class AssignmentArray<V extends Variable<V,T>,T extends Value<V,T>>

- java.lang.Object
- - org.cpsolver.ifs.assignment.AssignmentAbstract<V,T>
  - - org.cpsolver.ifs.assignment.AssignmentArray<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    Assignment<V,T>
  Direct Known Subclasses:
    InheritedAssignmentArray

      public class AssignmentArray<V extends Variable<V,T>,T extends Value<V,T>>
      extends AssignmentAbstract<V,T>

  An assignment using array to store values of all the variables of the model. `Variable.getIndex()` is used to index the array.
  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses.
  See Also:
    `Assignment`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Object[]` | `iAssignments`
    `protected Long[]` | `iIteration`

    - ### Fields inherited from class org.cpsolver.ifs.assignment.AssignmentAbstract

      `iContexts, iHasInitialzedContext`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AssignmentArray(AssignmentContextHolder<V,T> contexts)` Creates an empty assignment

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<T>` | `assignedValues()` The list of assigned values in the assignment.
    `Collection<V>` | `assignedVariables()` The list of assigned variables in the assignment.
    `long` | `getIteration(V variable)` Returns iteration of the last assignment.
    `protected T` | `getValueInternal(V variable)` Returns assignment of a variable, null if not assigned.
    `int` | `nrAssignedVariables()` Number of assigned variables in this assignment.
    `protected void` | `setValueInternal(long iteration, V variable, T value)` Sets an assignment to a variable (unassigns a variable if the given value is null).

    - ### Methods inherited from class org.cpsolver.ifs.assignment.AssignmentAbstract

      `assign, assign, clearContext, ensureInitializedContext, getAssignmentContext, getIndex, getValue, nrUnassignedVariables, unassign, unassign, unassignedVariables`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### iAssignments

          protected Object[] iAssignments

    - #### iIteration

          protected Long[] iIteration

  - ### Constructor Detail

    - #### AssignmentArray

          public AssignmentArray(AssignmentContextHolder<V,T> contexts)

      Creates an empty assignment
      Parameters:
        `contexts` - assignment context holder

  - ### Method Detail

    - #### getIteration

          public long getIteration(V variable)

      Description copied from interface: `Assignment`
      Returns iteration of the last assignment. Replacement for `Variable.getLastIteration()`.
      Parameters:
        `variable` - problem variable
      Returns:
        iteration of the last assignment

    - #### getValueInternal

          protected T getValueInternal(V variable)

      Description copied from class: `AssignmentAbstract`
      Returns assignment of a variable, null if not assigned. To be implemented.
      Specified by:
        `getValueInternal` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `variable` - a variable in question
      Returns:
        assigned value

    - #### setValueInternal

          protected void setValueInternal(long iteration,
                                          V variable,
                                          T value)

      Description copied from class: `AssignmentAbstract`
      Sets an assignment to a variable (unassigns a variable if the given value is null). To be implemented.
      Specified by:
        `setValueInternal` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `iteration` - current iteration
        `variable` - a variable to be assigned
        `value` - new assignment, null if to be unassigned

    - #### assignedVariables

          public Collection<V> assignedVariables()

      Description copied from interface: `Assignment`
      The list of assigned variables in the assignment. That is all the variables that `Assignment.getValue(Variable)` is not null in this assignment. Replacement for `Model.assignedVariables()`.
      Returns:
        a collection of assigned variable in this assignment

    - #### assignedValues

          public Collection<T> assignedValues()

      Description copied from interface: `Assignment`
      The list of assigned values in the assignment. That is a collection of `Assignment.getValue(Variable)` for all assigned variables in this assignment.
      Specified by:
        `assignedValues` in interface `Assignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Overrides:
        `assignedValues` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        a collection of assigned values in this assignment

    - #### nrAssignedVariables

          public int nrAssignedVariables()

      Description copied from interface: `Assignment`
      Number of assigned variables in this assignment. Replacement for `Model.nrAssignedVariables()`.
      Specified by:
        `nrAssignedVariables` in interface `Assignment<V extends Variable<V,T>,T extends Value<V,T>>`
      Overrides:
        `nrAssignedVariables` in class `AssignmentAbstract<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        number of assigned variables in this assignment