+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
de0e46f
master
1import java .io .*;import java .util .*; 2 3public class Util { 4public static int max (int a ,int b ) { 5if (a >b ) 6return a ; 7return b ; 8 } 9 10public static void mySleep (int time ) { 11try { 12Thread .sleep (time ); 13 }catch (InterruptedException e ) { 14 } 15 } 16 17public static void myWait (Object obj ) { 18println ("waiting" ); 19try { 20obj .wait (); 21 }catch (InterruptedException e ) { 22 } 23 } 24 25public static boolean lessThan (int A [],int B []) { 26for (int j =0 ;j <A .length ;j ++) 27if (A [j ] >B [j ]) 28return false ; 29for (int j =0 ;j <A .length ;j ++) 30if (A [j ] <B [j ]) 31return true ; 32return false ; 33 } 34 35public static int maxArray (int A []) { 36int v =A [0 ]; 37for (int i =0 ;i <A .length ;i ++) 38if (A [i ] >v ) 39v =A [i ]; 40return v ; 41 } 42 43public static String writeArray (int A []) { 44StringBuffer s =new StringBuffer (); 45for (int j =0 ;j <A .length ;j ++) 46s .append (String .valueOf (A [j ]) +" " ); 47return new String (s .toString ()); 48 } 49public static String readLine (InputStream sin )throws IOException { 50BufferedReader inp =new BufferedReader ( 51new InputStreamReader (sin )); 52return inp .readLine (); 53 } 54public static String readLine (String fileName )throws IOException { 55BufferedReader inp =new BufferedReader ( 56new FileReader (fileName )); 57return inp .readLine (); 58 } 59public static void readArray (String s ,int A []) { 60StringTokenizer st =new StringTokenizer (s ); 61for (int j =0 ;j <A .length ;j ++) 62A [j ] =Integer .parseInt (st .nextToken ()); 63 } 64 65public static void readList (String s ,LinkedList <Integer >q ) { 66StringTokenizer st =new StringTokenizer (s ); 67q .clear (); 68while (st .hasMoreTokens ()) { 69q .add (Integer .parseInt (st .nextToken ())); 70 } 71 } 72 73public static int searchArray (int A [],int x ) { 74for (int i =0 ;i <A .length ;i ++) 75if (A [i ] ==x ) 76return i ; 77return -1 ; 78 } 79 80public static void println (String s ) { 81if (Symbols .debugFlag ) { 82System .out .println (s ); 83System .out .flush (); 84 } 85 } 86 87public static LinkedList <Object >getLinkedList (Object ...objects ) { 88LinkedList <Object >list =new LinkedList <Object >(); 89for (int i =0 ;i <objects .length ;i +=1 ) { 90list .add (objects [i ]); 91 } 92return list ; 93 } 94}