// Source code example for "A Practical Introduction // to Data Structures and Algorithm Analysis" // by Clifford A. Shaffer, Prentice Hall, 1998. // Copyright 1998 by Clifford A. Shaffer import java.io.*; // Driver class for Memory Manager tests. public class MemMain { public static void main(String args[]) throws IOException { MemManager mymem = new MemManImpl(15); // New pool of 15 items int[] stuff = new int[3]; for (int i=0; i<3; i++) // Gin up some sample data stuff[i] = i+10; System.out.println("Do first request"); MemHandle h = mymem.request(stuff); // Stick it in the memory pool // Now, get it back and make sure it is right. int[] dum = mymem.getValue(h); for(int i=0; i<3; i++) System.out.print(dum[i] + " "); System.out.println(); System.out.println("Do second request"); // Stick in another copy. MemHandle h2 = mymem.request(stuff); mymem.release(h); // Now, release the first block. System.in.read(); } // main } // class MemMain