table fixes and notes

This commit is contained in:
Ben Fry
2014-07-10 14:18:40 -04:00
parent 84d2280af4
commit 7a6018b8e2
3 changed files with 36 additions and 6 deletions

View File

@@ -159,6 +159,7 @@ public class Table {
for (TableRow row : rows) {
if (!typed) {
setColumnTypes(row.getColumnTypes());
typed = true;
}
addRow(row);
}
@@ -417,6 +418,10 @@ public class Table {
char[] c = new char[100];
int count = 0;
boolean insideQuote = false;
int alloc = 100;
setRowCount(100);
int row = 0;
int col = 0;
int ch;
@@ -462,14 +467,23 @@ public class Table {
}
setString(row, col, new String(c, 0, count));
count = 0;
if (row == 0 && header) {
row++;
if (row == 1 && header) {
// Use internal row removal (efficient because only one row).
removeTitleRow();
// Un-set the header variable so that next time around, we don't
// just get stuck into a loop, removing the 0th row repeatedly.
header = false;
// Reset the number of rows (removeTitleRow() won't reset our local 'row' counter)
row = 0;
}
// if (row % 1000 == 0) {
// PApplet.println(PApplet.nfc(row));
// }
if (row == alloc) {
alloc *= 2;
setRowCount(alloc);
}
row++;
col = 0;
} else if (ch == ',') {
@@ -491,6 +505,9 @@ public class Table {
if (count > 0) {
setString(row, col, new String(c, 0, count));
}
if (alloc != row) {
setRowCount(row); // shrink to the actual size
}
}