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