public class Resource extends Object
| Constructor and Description |
|---|
Resource(int size)
Allocate storage for a new instance of Resource.
|
| Modifier and Type | Method and Description |
|---|---|
int |
allocate()
Allocate a resource.
|
int |
allocate(int index)
Allocate a specific resource value.
|
void |
free(int index)
Free an allocated resource.
|
static void |
restartProgram()
Clears all allocated resources
|
public Resource(int size)
size - The number of blocks to allocatepublic static void restartProgram()
public int allocate()
throws CheckedAllocationException
CheckedAllocationException - If there are no resources available to be allocated.public int allocate(int index)
throws CheckedAllocationException
index - The resource to allocateCheckedAllocationException - If there are no resources available to be allocated.public void free(int index)
index - The index of the resource to free.Copyright © 2015. All rights reserved.