|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| Pair.java | - | 85.7% | 83.3% | 84.6% |
|
||||||||||||||
| 1 | /*BEGIN_COPYRIGHT_BLOCK | |
| 2 | * | |
| 3 | * Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu). All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | |
| 6 | * following conditions are met: | |
| 7 | * * Redistributions of source code must retain the above copyright notice, this list of conditions and the | |
| 8 | * following disclaimer. | |
| 9 | * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the | |
| 10 | * following disclaimer in the documentation and/or other materials provided with the distribution. | |
| 11 | * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the names of its contributors may be used | |
| 12 | * to endorse or promote products derived from this software without specific prior written permission. | |
| 13 | * | |
| 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | |
| 15 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 16 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 17 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 18 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 19 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 20 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 21 | * | |
| 22 | * This software is Open Source Initiative approved Open Source Software. Open Source Initative Approved is a trademark | |
| 23 | * of the Open Source Initiative. | |
| 24 | * | |
| 25 | * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/ or | |
| 26 | * http://sourceforge.net/projects/drjava/ | |
| 27 | * | |
| 28 | * END_COPYRIGHT_BLOCK*/ | |
| 29 | ||
| 30 | package edu.rice.cs.javalanglevels; | |
| 31 | ||
| 32 | /** Utility class, allows us to store two things as a single object. */ | |
| 33 | public class Pair<T,U> { | |
| 34 | T _first; | |
| 35 | U _second; | |
| 36 | ||
| 37 | 1132 | public Pair(T first, U second) { |
| 38 | 1132 | _first = first; |
| 39 | 1132 | _second = second; |
| 40 | } | |
| 41 | ||
| 42 | 2408 | public T getFirst() { return _first; } |
| 43 | ||
| 44 | 957 | public U getSecond() { return _second; } |
| 45 | ||
| 46 | 654 | public boolean equals(Object o) { |
| 47 | 654 | return (o != null) && (o.getClass() == this.getClass()) && |
| 48 | getFirst().equals(((Pair) o).getFirst()) && getSecond().equals(((Pair) o).getSecond()); | |
| 49 | } | |
| 50 | ||
| 51 | /** Define a hash code based on the first and second's hash code */ | |
| 52 | 0 | public int hashCode() { return _first.hashCode() ^ _second.hashCode(); } |
| 53 | ||
| 54 | 10 | public String toString() { return "Pair(" + _first + ", " + _second + ")"; } |
| 55 | } |
|
||||||||||