Skip to content

Commit b86f9c8

Browse files
add two utils classes
1 parent 8c55fda commit b86f9c8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.fishercoder.common.classes;
2+
3+
import java.util.List;
4+
5+
public interface BinaryMatrix {
6+
int get(int x, int y);
7+
8+
List<Integer> dimensions();
9+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.fishercoder.common.classes;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class BinaryMatrixImpl implements BinaryMatrix {
7+
8+
private final int[][] matrix;
9+
10+
public BinaryMatrixImpl(int[][] matrix) {
11+
this.matrix = matrix;
12+
}
13+
14+
@Override
15+
public int get(int x, int y) {
16+
return matrix[x][y];
17+
}
18+
19+
@Override
20+
public List<Integer> dimensions() {
21+
List<Integer> dimensions = new ArrayList<>();
22+
dimensions.add(matrix.length);
23+
dimensions.add(matrix[0].length);
24+
return dimensions;
25+
}
26+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy