List of usage examples for android.util SparseArray put
public void put(int key, E value)
From source file:Main.java
private static double getTheoreticalStudent(int n) { SparseArray<Double> theorStudent = new SparseArray<Double>(); theorStudent.put(10, 2.2281389); theorStudent.put(20, 2.0859634);/* w ww . j a v a 2 s . c o m*/ theorStudent.put(30, 2.0422725); theorStudent.put(40, 2.0210754); theorStudent.put(50, 2.0085591); theorStudent.put(60, 2.0002978); theorStudent.put(70, 1.9944371); if (n >= 70) return theorStudent.get(70); else if (n >= 60) return theorStudent.get(60); else if (n >= 50) return theorStudent.get(50); else if (n >= 40) return theorStudent.get(40); else if (n >= 30) return theorStudent.get(30); else if (n >= 20) return theorStudent.get(20); else if (n >= 10) return theorStudent.get(10); else return theorStudent.get(10); }
From source file:Main.java
public static SparseArray<Float> compartmentsMaxValues(SparseArray<ArrayList<Float>> compartments) { SparseArray<Float> maxValues = new SparseArray<>(); for (int i = 0; i < compartments.size(); i++) { maxValues.put(i, Collections.max(compartments.get(i))); }//from w w w. j a va 2 s . co m return maxValues; }
From source file:Main.java
/** * @return theoretical fishers table//from ww w . j a va2 s .co m * table realized by SparseArray, in connection with better performance than HashMap */ private static Double getTheoreticalFisher(int n) { SparseArray<Double> theorFisher = new SparseArray<Double>(); theorFisher.put(1, 12.706); theorFisher.put(2, 4.3027); theorFisher.put(3, 3.1825); theorFisher.put(4, 2.7764); theorFisher.put(5, 2.5706); theorFisher.put(6, 2.4469); theorFisher.put(7, 2.3646); theorFisher.put(8, 2.3060); theorFisher.put(9, 2.2622); theorFisher.put(10, 2.2281); theorFisher.put(11, 2.2010); theorFisher.put(12, 2.1788); theorFisher.put(13, 2.1604); theorFisher.put(14, 2.1448); theorFisher.put(15, 2.1315); theorFisher.put(16, 2.1199); theorFisher.put(17, 2.1098); theorFisher.put(18, 2.1009); theorFisher.put(19, 2.0930); theorFisher.put(20, 2.0860); theorFisher.put(30, 2.0423); theorFisher.put(40, 2.0211); theorFisher.put(60, 2.0003); if (n >= 60) { return theorFisher.get(60); } else if (n >= 40) { return theorFisher.get(40); } else if (n >= 30) { return theorFisher.get(30); } else if (n >= 20) { return theorFisher.get(20); } else { return theorFisher.get(n); } }
From source file:com.chess.genesis.dialog.GameStatsDialog.java
private static SparseArray<String[]> createMap() { final SparseArray<String[]> map = new SparseArray<String[]>(); map.put(Piece.WHITE * Enums.WHITEMATE, WON_CHECK); map.put(Piece.WHITE * Enums.BLACKMATE, LOST_CHECK); map.put(Piece.WHITE * Enums.WHITERESIGN, LOST_RESIGN); map.put(Piece.WHITE * Enums.BLACKRESIGN, WON_RESIGN); map.put(Piece.WHITE * Enums.IMPOSSIBLE, TIED_IMP); map.put(Piece.WHITE * Enums.STALEMATE, TIED_STALE); map.put(Piece.WHITE * Enums.WHITEIDLE, LOST_IDLE); map.put(Piece.WHITE * Enums.BLACKIDLE, WON_IDLE); map.put(Piece.WHITE * Enums.DRAW, DRAW_GAME); map.put(Piece.BLACK * Enums.WHITEMATE, LOST_CHECK); map.put(Piece.BLACK * Enums.BLACKMATE, WON_CHECK); map.put(Piece.BLACK * Enums.WHITERESIGN, WON_RESIGN); map.put(Piece.BLACK * Enums.BLACKRESIGN, LOST_RESIGN); map.put(Piece.BLACK * Enums.IMPOSSIBLE, TIED_IMP); map.put(Piece.BLACK * Enums.STALEMATE, TIED_STALE); map.put(Piece.BLACK * Enums.WHITEIDLE, WON_IDLE); map.put(Piece.BLACK * Enums.BLACKIDLE, LOST_IDLE); map.put(Piece.BLACK * Enums.DRAW, DRAW_GAME); return map;// w w w .jav a2 s . co m }
From source file:Main.java
public static void scaleBitmaps(SparseArray<Bitmap> bitmapMap, float scale) { for (int i = 0; i < bitmapMap.size(); i++) { int key = bitmapMap.keyAt(i); Log.d("BitmapUtil", "scaleBitmaps: " + key); Bitmap bitmap = bitmapMap.get(key); bitmapMap.put(i, scaleBitmap(bitmap, scale)); }//from w w w . j ava 2 s .c o m }
From source file:Main.java
public static <E> SparseArray<E> putAll(SparseArray<E> source, SparseArray<E> dest) { if (dest == null) dest = source;/*from www .java 2 s.c o m*/ else if (source != null) for (int i = 0; i < source.size(); i++) { int key = source.keyAt(i); E value = source.valueAt(i); dest.put(key, value); } return dest; }
From source file:Main.java
public static <T> void addInArray(SparseArray<SparseArray<T>> array, int firstKey, int secondKey, T value) { if (array == null) return;// w ww .j a v a2 s . c o m SparseArray<T> ts = array.get(firstKey); if (ts == null) { ts = new SparseArray<T>(); synchronized (array) { array.put(firstKey, ts); } } synchronized (array) { ts.put(secondKey, value); } }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T extends View> T getViewByHolder(View view, int id) { SparseArray<View> viewHolder = (SparseArray<View>) view.getTag(); if (viewHolder == null) { viewHolder = new SparseArray<View>(); view.setTag(viewHolder);//from ww w .ja v a 2 s. c om } View childView = viewHolder.get(id); if (childView == null) { childView = view.findViewById(id); viewHolder.put(id, childView); } return (T) childView; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T extends View> T get(View view, int id) { SparseArray<View> viewHolder = (SparseArray<View>) view.getTag(); if (viewHolder == null) { viewHolder = new SparseArray<View>(); view.setTag(viewHolder);/*from www.ja va2 s. co m*/ } View childView = viewHolder.get(id); if (childView == null) { childView = view.findViewById(id); viewHolder.put(id, childView); } return (T) childView; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T extends View> T obtainView(View convertView, int id) { SparseArray<View> holder = (SparseArray<View>) convertView.getTag(); if (holder == null) { holder = new SparseArray<View>(); convertView.setTag(holder);/*w w w.j av a2 s .co m*/ } View childView = holder.get(id); if (childView == null) { childView = convertView.findViewById(id); holder.put(id, childView); } return (T) childView; }