• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Jul 16th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Path[1] = a
2. Path[2] = a,b
3. Path[3] = a,b,c
4. Path[4] = a,.........
5. ......
6. ......
7.
8. ArrayList<String> array = new ArrayList<> ();
9.
10. ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>> ();
11.
12. ArrayList<String> row1 = new ArrayList<> ();
19.
20. list.get(0).get(3)
21.
22. for (ArrayList<String> oneList : list) {
23.     for (String s : oneList) {
24.     }
25. }
26.
27. ArrayList<ArrayList<Integer[]>> path = new ArrayList<>();
28.
29. ArrayList<Integer[]> path1 = path.get(0);
30. Integer[] a = path1.get(0);
31. ArrayList<Integer[]> path2 = path.get(1);
32. Integer[] a2 = path1.get(0);
33. Integer[] b2 = path1.get(0);
34.
35. for(ArrayList<Integer[]> list : path) {
36.         for(Integer[] values : list) {
37.             for(Integer value : values) {
38.                 System.out.println(value);
39.             }
40.         }
41.     }
42.
43. int value = path.get(0).get(0)[0];
44.
45. path.get(0).get(0)[0] = 12;
46.
47. public class MyMatrix<T> {
48.     private ArrayList<ArrayList<T>> data;
49.
50.     public MyMatrix() {
51.         data = new ArrayList<ArrayList<>>();
52.     }
53.
54.     // add methods like the ones below, depending on what you need:
55.
56.     public void set(T t, int x, int y) {
57.         // exercises for the reader:
58.         // - check bounds (x and y > 0)
59.         // - check that row x exists, if not add rows
60.         // - check that column y exists, if not, add columns in target row
61.         // - if matrix needs to be flush (i.e., all lines need the same number of columns, extend all columns as needed
62.         data.get(x).set(y, t);
63.     }
64.
65.     T get(int x, int y) {
66.          // todo: sanity check x and y
67.          return data.get(x).get(y);
68.     }
69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?