summaryrefslogtreecommitdiffstats
path: root/partition.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-30 09:51:04 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-30 09:51:04 -0400
commit6fa9ed77f6e124691e588bdb70f21d3aa10f30e8 (patch)
tree568a438e11ad005fd6bd0a20f5d28d331844a697 /partition.c
parentef0ba48ead218d37d979b5ca156ea9d557754dd6 (diff)
downloadballs-6fa9ed77f6e124691e588bdb70f21d3aa10f30e8.zip
create collision buffers
Diffstat (limited to 'partition.c')
-rw-r--r--partition.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/partition.c b/partition.c
index 354e033..b7229d6 100644
--- a/partition.c
+++ b/partition.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <stdio.h>
#include "sysfatal.h"
#include "balls.h"
@@ -52,6 +53,19 @@ freePartition(Partition part) {
free(part.cells);
}
+void
+printPartition(Partition part) {
+ size_t i, j;
+
+ for (i = 0; i < part.size; i++) {
+ printf("{");
+ for (j = 0; j < part.cells[i].size; j++)
+ printf("(%lu, %lu), ", part.cells[i].ballIndices[j][0],
+ part.cells[i].ballIndices[j][1]);
+ printf("}\n");
+ }
+}
+
/* Allocate an empty partition. Partition should be freed by the caller after use. */
static Partition
newPartition(void) {