aim4.im.v2i.reservation

## Class ReservationArray

- java.lang.Object
- - aim4.im.v2i.reservation.ReservationArray

- Direct Known Subclasses:
    ReservationGrid

      public class ReservationArray
      extends Object

  The Reservation Array.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ReservationArray.TimeTile` The smallest unit of space-time in the FCFS policy.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReservationArray(int numOfTiles)` Create a new reservation system.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `cancel(int rid)` Cancel a reservation
    `void` | `cleanUp(int dt)` Remove all reservations before a given discrete time.
    `int` | `getLastReservedDiscreteTime()` Get the last time at which any time-tile has been reserved.
    `int` | `getLastReservedDiscreteTime(int rid)` Get the last discrete time of a particular reservation ID.
    `int` | `getNumberOfTiles()` Get the number of tiles
    `int` | `getReservationId(int dt, int tid)` Get the reservation ID that reserved the given time-tile.
    `List<Integer>` | `getReservedTilesAtTime(int dt)` Get the set of all reserved tiles at a given discrete time.
    `Set<Integer>` | `getVinOfReservedTilesAtTime(int dt)` Get the VINs of all reserved tiles at a given discrete time.
    `boolean` | `hasReservation(int rid)` Check whether a given reservation ID exists
    `boolean` | `isReserved(int dt, int tid)` Whether the time-tile has been reserved.
    `boolean` | `reserve(int rid, Collection<? extends ReservationArray.TimeTile> workingList)` Make the reservation of a set of time-tiles with a given reservation id.

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

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

- - ### Constructor Detail

    - #### ReservationArray

          public ReservationArray(int numOfTiles)

      Create a new reservation system.
      Parameters:
        `numOfTiles` - The number of tiles in the intersection

  - ### Method Detail

    - #### getNumberOfTiles

          public int getNumberOfTiles()

      Get the number of tiles

    - #### isReserved

          public boolean isReserved(int dt,
                           int tid)

      Whether the time-tile has been reserved.
      Parameters:
        `dt` - the discrete time
        `tid` - the tile ID

    - #### getReservationId

          public int getReservationId(int dt,
                             int tid)

      Get the reservation ID that reserved the given time-tile.
      Parameters:
        `dt` - the discrete time
        `tid` - the id of the tile
      Returns:
        the reservation ID; -1 if the reservation ID does not exist

    - #### hasReservation

          public boolean hasReservation(int rid)

      Check whether a given reservation ID exists
      Parameters:
        `rid` - the reservation ID
      Returns:
        whether the reservation ID exists

    - #### getLastReservedDiscreteTime

          public int getLastReservedDiscreteTime()

      Get the last time at which any time-tile has been reserved.
      Returns:
        the last time at which any time-tile has been reserved; -1 if there is currently no reservation.

    - #### getLastReservedDiscreteTime

          public int getLastReservedDiscreteTime(int rid)

      Get the last discrete time of a particular reservation ID.
      Parameters:
        `rid` - the reservation ID
      Returns:
        the last discrete time of the reservation; less than zero if the reservation id does not exist

    - #### reserve

          public boolean reserve(int rid,
                        Collection<? extends ReservationArray.TimeTile> workingList)

      Make the reservation of a set of time-tiles with a given reservation id. If the reservation is not successful, no time-tiles will be reserved.
      Parameters:
        `rid` - the reservation ID
        `workingList` - a collection of time-tiles to be reserved
      Returns:
        whether the reservation is successful

    - #### cancel

          public boolean cancel(int rid)

      Cancel a reservation
      Parameters:
        `rid` - the reservation ID
      Returns:
        whether the cancellation is successful

    - #### cleanUp

          public void cleanUp(int dt)

      Remove all reservations before a given discrete time.
      Parameters:
        `dt` - the discrete time before which the reservations will be removed.

    - #### getReservedTilesAtTime

          public List<Integer> getReservedTilesAtTime(int dt)

      Get the set of all reserved tiles at a given discrete time.
      Parameters:
        `dt` - the discrete time
      Returns:
        the list of tile IDs that are reserved at the given discrete time.

    - #### getVinOfReservedTilesAtTime

          public Set<Integer> getVinOfReservedTilesAtTime(int dt)

      Get the VINs of all reserved tiles at a given discrete time.
      Parameters:
        `dt` - the discrete time
      Returns:
        a set of reservation IDs.

Copyright © 2013. All rights reserved.