-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6df5b12
commit 5379a7f
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* schedule.cpp | ||
* | ||
* Implementation of a schedule | ||
*/ | ||
|
||
#include <string.h> | ||
|
||
#include "schedule.h" | ||
|
||
schedule_t* schedule_init (std::string name, int itSetSize, int* iter2tile, | ||
int* iter2color, direction_t direction) | ||
{ | ||
schedule_t* schedule = new schedule_t; | ||
|
||
schedule->name = name; | ||
schedule->itSetSize = itSetSize; | ||
schedule->iter2tile = iter2tile; | ||
schedule->iter2color = iter2color; | ||
schedule->direction = direction; | ||
|
||
return schedule; | ||
} | ||
|
||
schedule_t* schedule_cpy (schedule_t* toCopy) | ||
{ | ||
schedule_t* schedule = new schedule_t; | ||
|
||
schedule->name = toCopy->name; | ||
schedule->itSetSize = toCopy->itSetSize; | ||
schedule->iter2tile = new int[toCopy->itSetSize]; | ||
schedule->iter2color = new int[toCopy->itSetSize]; | ||
schedule->direction = toCopy->direction; | ||
|
||
memcpy (schedule->iter2tile, toCopy->iter2tile, sizeof(int)*toCopy->itSetSize); | ||
memcpy (schedule->iter2color, toCopy->iter2color, sizeof(int)*toCopy->itSetSize); | ||
|
||
return schedule; | ||
} | ||
|
||
void schedule_free (schedule_t* schedule) | ||
{ | ||
if (! schedule) { | ||
return; | ||
} | ||
delete[] schedule->iter2tile; | ||
delete[] schedule->iter2color; | ||
delete schedule; | ||
} | ||
|
||
projection_t* projection_init() | ||
{ | ||
return new projection_t (&schedule_cmp); | ||
} | ||
|
||
void projection_free (projection_t* projection) | ||
{ | ||
projection_t::iterator it, end; | ||
for (it = projection->begin(), end = projection->end(); it != end; it++) { | ||
schedule_free(*it); | ||
} | ||
delete projection; | ||
} |