Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cc20933

Browse files
committed
VisualSortArray, SortCanvas: Changed getState() to return an object instead of an ordinal index.
1 parent 4d054d9 commit cc20933

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

‎src/io/nayuki/sortalgodemo/visual/SortCanvas.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void update(Graphics g) {
8080
bufGfx.setColor(BACKGROUND_COLOR);
8181
bufGfx.fillRect(0, 0, array.length() * scale, array.length() * scale);
8282
for (int i = 0; i < array.length(); i++) {
83-
bufGfx.setColor(STATE_COLORS[array.getState(i)]);
83+
bufGfx.setColor(STATE_COLORS[array.getState(i).ordinal()]);
8484
int val = array.getValue(i);
8585
if (scale == 1)
8686
bufGfx.drawLine(0, i, val, i);

‎src/io/nayuki/sortalgodemo/visual/VisualSortArray.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ final class VisualSortArray extends AbstractSortArray {
3939

4040
private boolean isInitialized = false;
4141

42-
// Visual state per element: 0=active, 1=inactive, 2=comparing, 3=done
4342
private AtomicReferenceArray<ElementState> states;
4443

4544
private volatile boolean isDone;
@@ -146,8 +145,8 @@ public int getValue(int index) {
146145
}
147146

148147

149-
public int getState(int index) {
150-
return states.getOpaque(index).ordinal();
148+
public ElementState getState(int index) {
149+
return states.getOpaque(index);
151150
}
152151

153152

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /