[LIB-9] Chessboard squares sorting
[chesshog.git] / src / main / java / org / hedgecode / chess / position / DiagramPosition.java
index e12b477..1d28759 100644 (file)
@@ -18,6 +18,7 @@ package org.hedgecode.chess.position;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.TreeMap;
 
 /**
  *
@@ -55,6 +56,19 @@ public class DiagramPosition implements Position {
     }
 
     @Override
+    public Map<Square, ColorPiece> getSquares(SquareSort sorting) {
+        if (sorting == null)
+            sorting = SquareSort.defaultSort();
+
+        TreeMap<Square, ColorPiece> sortedSquares = new TreeMap<>(
+                sorting.comparator()
+        );
+        sortedSquares.putAll(squares);
+
+        return sortedSquares;
+    }
+
+    @Override
     public Map<Square, ColorPiece> getSquarePieces(Color color) {
         return getSquarePieces(color, null);
     }