Created
May 3, 2016 05:00
-
-
Save bhnascar/86f716eca9c3e3242d5f9574a3aa43ae to your computer and use it in GitHub Desktop.
2015 #3 part b
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
public void removeCol(int col) { | |
for (int i = entries.size() - 1; i >= 0; i--) { | |
SparseArrayEntry entry = entries.get(i); | |
if (entry.getCol() > col) { | |
// Fix the column number for this item because it's in a column | |
// to the right of the column we're removing | |
SparseArrayEntry fixedEntry = new SparseArrayEntry(entry.getRow(), | |
entry.getCol() - 1, | |
entry.getValue()); | |
entries.set(i, fixedEntry); | |
} | |
else if (entry.getCol() == col) { | |
// Remove this item because it's inside the column we're removing | |
entries.remove(i); | |
} | |
} | |
// Update the numCols variable since we removed one column. | |
numCols--; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment