Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: Allocator/MemUnitComparator.java


1   // MemUnitComparator.java, created Mon Nov 25  9:05:34 2002 by laudney
2   // Copyright (C) 2001-3 laudney <laudney@acm.org>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package Allocator;
5   
6   import java.util.Comparator;
7   
8   /**
9    * MemUnitComparator
10   *
11   * @author laudney <laudney@acm.org>
12   * @version $Id: MemUnitComparator.java,v 1.3 2003/05/12 10:04:52 joewhaley Exp $
13   */
14  public class MemUnitComparator implements Comparator {
15      public int compare(Object o1, Object o2) {
16          if(!(o1 instanceof MemUnit && o2 instanceof MemUnit)) {
17              throw new ClassCastException();
18          } else {
19              return (((MemUnit)o1).getByteLength() - ((MemUnit)o2).getByteLength());
20          }
21      }
22  }