List of usage examples for java.lang Integer MAX_VALUE
int MAX_VALUE
To view the source code for java.lang Integer MAX_VALUE.
Click Source Link
From source file:Main.java
/** * Checks whether the recording service is currently running. * /*from ww w .j a va 2 s .c o m*/ * @param ctx * the current context * @return true if the service is running, false otherwise */ public static boolean isServiceRunning(final Context ctx, final Class<?> cls) { final ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); final List<RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE); for (final RunningServiceInfo serviceInfo : services) { final ComponentName componentName = serviceInfo.service; final String serviceName = componentName.getClassName(); if (serviceName.equals(cls.getName())) { return true; } } return false; }
From source file:Main.java
public static void copyCompletely(InputStream input, OutputStream output) throws IOException { // if both are file streams, use channel IO if ((output instanceof FileOutputStream) && (input instanceof FileInputStream)) { try {// w ww .j a va 2 s . co m FileChannel target = ((FileOutputStream) output).getChannel(); FileChannel source = ((FileInputStream) input).getChannel(); source.transferTo(0, Integer.MAX_VALUE, target); source.close(); target.close(); return; } catch (Exception e) { /* failover to byte stream version */ } } byte[] buf = new byte[8192]; while (true) { int length = input.read(buf); if (length < 0) break; output.write(buf, 0, length); } try { input.close(); } catch (IOException ignore) { } try { output.close(); } catch (IOException ignore) { } }
From source file:gov.jgi.meta.hadoop.input.FastqBlockLineReader.java
public static void main(String[] args) { int num = 100; int last = -1; do {// w w w.ja v a 2s.c om try { FileInputStream fstream = new FileInputStream("/ifs/scratch/karan/derep-perf/HiSeq-8343080.fq"); FastqBlockLineReader fblr = new FastqBlockLineReader(fstream); Text key = new Text(); Map<String, String> setofreads = new HashMap<String, String>(); int length = (int) (Math.random() * 1000000); System.out.println("iteration " + num + " length = " + length); int total = 0; fblr.readLine(key, setofreads, Integer.MAX_VALUE, length); // System.out.println("setofreads.size = " + setofreads.size()); total += setofreads.size(); //for (String s : setofreads.keySet()) { // System.out.println(s); // } int m = 0; while (setofreads.size() > 0) { System.out.print("."); if ((++m) % 80 == 0) System.out.print("\n"); setofreads.clear(); fblr.readLine(key, setofreads, Integer.MAX_VALUE, length); // System.out.println("setofreads.size = " + setofreads.size()); total += setofreads.size(); } System.out.println("\ntotal = " + total); if (last != -1) { if (last != total) { System.out.println( "error!!!, length = " + length + ": last = " + last + " current = " + total); } } last = total; } catch (Exception e) { System.out.println(e); } } while (num-- > 0); }
From source file:com.evolveum.midpoint.schema.PagingTypeFactory.java
public static PagingType createPaging(int offset, OrderDirectionType order, String orderBy) { return createPaging(offset, Integer.MAX_VALUE, order, orderBy); }
From source file:Main.java
/** * There are should be at least 4 bytes in input stream. Otherwise result may be not defined. * If input stream contains no more data, method return {@link Integer#MAX_VALUE}. * //from w ww .ja v a 2 s . c om * @param input * @return Next Integer from input stream. * @throws IOException */ public static int readInt(InputStream input) throws IOException { int value = Integer.MAX_VALUE; int buf; if ((buf = input.read()) != -1) { value = buf; value = value | (input.read() << 8); value = value | (input.read() << 16); value = value | (input.read() << 24); } return value; }
From source file:Main.java
public static <E> List<E> asList(E... elements) { if (elements == null || elements.length == 0) { return Collections.emptyList(); }//from ww w .j a v a2s . com // Avoid integer overflow when a large array is passed in int capacity = (int) Math.min(5L + elements.length + (elements.length / 10), Integer.MAX_VALUE); ArrayList<E> list = new ArrayList<E>(capacity); Collections.addAll(list, elements); return list; }
From source file:Main.java
/** * Returns a capacity that is sufficient to keep the map from being resized as long as it grows no * larger than expectedSize and the load factor is >= its default (0.75). */// ww w.j av a 2 s .c o m private static int capacity(int expectedSize) { if (expectedSize < 3) { checkNonnegative(expectedSize, "expectedSize"); return expectedSize + 1; } if (expectedSize < MAX_POWER_OF_TWO) { // This is the calculation used in JDK8 to resize when a putAll // happens; it seems to be the most conservative calculation we // can make. 0.75 is the default load factor. return (int) ((float) expectedSize / 0.75F + 1.0F); } return Integer.MAX_VALUE; // any large value }
From source file:gov.jgi.meta.hadoop.input.FastaBlockLineReader.java
public static void main(String[] args) { int num = 1;//from www . j av a 2 s.co m int last = -1; do { try { FileInputStream fstream = new FileInputStream("/scratch/karan/30mb.fas"); FastaBlockLineReader fblr = new FastaBlockLineReader(fstream); Text key = new Text(); Map<String, String> setofreads = new HashMap<String, String>(); Map<String, String> setofreadsTotal = new HashMap<String, String>(); int length = (int) (Math.random() * 10000); length = 3000000; System.out.println("lenght = " + length); int total = 0; fblr.readLine(key, setofreads, Integer.MAX_VALUE, length); // System.out.println("setofreads.size = " + setofreads.size()); total += setofreads.size(); //for (String s : setofreads.keySet()) { // System.out.println(s); // } Runtime r = Runtime.getRuntime(); while (setofreads.size() > 0) { setofreadsTotal.putAll(setofreads); setofreads.clear(); fblr.readLine(key, setofreads, Integer.MAX_VALUE, length); // System.out.println("setofreads.size = " + setofreads.size()); total += setofreads.size(); r.gc(); } System.out.println("total = " + total); System.out.println("heap size = " + r.totalMemory() / 1048576); if (last != -1) { if (last != total) { System.out.println( "error!!!, length = " + length + ": last = " + last + " current = " + total); } } last = total; } catch (Exception e) { System.out.println(e); } } while (num-- > 0); }
From source file:datamine.storage.idl.generator.RandomValueGenerator.java
public static Object getValueOf(PrimitiveType type) { switch (type) { case BOOL:/*from w ww .jav a 2s . c om*/ return rand1.nextBoolean(); case BYTE: return (byte) rand1.nextInt(Byte.MAX_VALUE); case INT16: return (short) rand1.nextInt(Short.MAX_VALUE); case INT32: return rand1.nextInt(Integer.MAX_VALUE); case INT64: return rand1.nextLong(); case FLOAT: return rand1.nextFloat(); case DOUBLE: return rand1.nextDouble(); case STRING: return "abasf_" + System.currentTimeMillis();//rand2.random(256); case BINARY: byte[] ret = new byte[1000]; rand1.nextBytes(ret); return ret; case UNKNOWN: return null; default: throw new IllegalArgumentException("Not support the type: " + type); } }
From source file:Main.java
/** * Find the smallest area that contains multiples rect defined by width & height * * @param width//from ww w.j a va2 s.c o m * @param height * @param num * @return */ public static Point getSmallestTextureSize(final int width, final int height, final int num, final int maxTextureSize, final boolean forcePo2) { int minWidth = 0; int minHeight = 0; int minArea = Integer.MAX_VALUE; for (int row = 1; row <= num; row++) { int col = (int) Math.ceil((float) num / (float) row); int po2Width = forcePo2 ? getNextPO2(col * width) : col * width; int po2Height = forcePo2 ? getNextPO2(row * height) : row * height; int area = po2Width * po2Height; if (area < minArea && po2Width <= maxTextureSize) { minArea = area; minWidth = po2Width; minHeight = (po2Height < maxTextureSize) ? po2Height : maxTextureSize; } } return new Point(minWidth, minHeight); }