1 | /* |
2 | * Copyright 2008 Eric Caspole |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this |
5 | * file except in compliance with the License. You may obtain a copy of the License at |
6 | * |
7 | * http://www.apache.org/licenses/LICENSE-2.0 |
8 | * |
9 | * Unless required by applicable law or agreed to in writing, software distributed under |
10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
11 | * KIND, either express or implied. See the License for the specific language governing |
12 | * permissions and limitations under the License. |
13 | */ |
14 | package net.sf.madmap; |
15 | |
16 | import java.util.Comparator; |
17 | |
18 | public class SizeComparator implements Comparator { |
19 | |
20 | public int compare( Object aa, Object bb ) { |
21 | |
22 | HprofClassElement a = (HprofClassElement) aa; |
23 | HprofClassElement b = (HprofClassElement) bb; |
24 | |
25 | /* |
26 | if ( a.getInstanceCount() < b.getInstanceCount() ) { |
27 | return -1; |
28 | } else if ( a.getInstanceCount() == b.getInstanceCount() ) { |
29 | return 0; |
30 | } else { |
31 | return 1; |
32 | } |
33 | */ |
34 | |
35 | long aSize = a.getInstanceSize(); |
36 | long bSize = b.getInstanceSize(); |
37 | |
38 | if ( aSize > bSize ) { |
39 | return -1; |
40 | } else if ( aSize == bSize ) { |
41 | return 0; |
42 | } else { |
43 | return 1; |
44 | } |
45 | } |
46 | } |