source: branches/MetisMQI/src/main/java/weka/classifiers/EnsembleLibraryModelComparator.java @ 32

Last change on this file since 32 was 29, checked in by gnappo, 14 years ago

Taggata versione per la demo e aggiunto branch.

File size: 2.2 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 *    EnsembleLibraryModelComparator.java
19 *    Copyright (C) 2006 Robert Jung
20 *
21 */
22
23package weka.classifiers;
24
25import weka.core.RevisionHandler;
26import weka.core.RevisionUtils;
27
28import java.io.Serializable;
29import java.util.Comparator;
30
31/**
32 * This class is a Comparator for the LibraryModel class. It basically ranks
33 * them alphabetically based on their String Representations
34 *
35 * @author  Robert Jung (mrbobjung@gmail.com)
36 * @version $Revision: 6041 $
37 */
38public final class EnsembleLibraryModelComparator
39  implements Comparator, Serializable, RevisionHandler {
40
41  /** for serialization */
42  private static final long serialVersionUID = -6522464740036141188L;
43
44  /**
45   * Compares its two arguments for order.
46   *
47   * @param o1          first object
48   * @param o2          second object
49   * @return            a negative integer, zero, or a positive integer as the
50   *                    first argument is less than, equal to, or greater than
51   *                    the second.
52   */
53  public int compare(Object o1, Object o2) {
54
55    int comparison = 0;
56
57    if (o1 instanceof EnsembleLibraryModel
58        && o2 instanceof EnsembleLibraryModel) {
59
60      comparison = ((String) ((EnsembleLibraryModel) o1)
61          .getStringRepresentation())
62        .compareTo(((String) ((EnsembleLibraryModel) o2)
63              .getStringRepresentation()));
64
65    }
66
67    return comparison;
68  }
69
70  /**
71   * Returns the revision string.
72   *
73   * @return            the revision
74   */
75  public String getRevision() {
76    return RevisionUtils.extract("$Revision: 6041 $");
77  }
78}
Note: See TracBrowser for help on using the repository browser.