Last change
on this file since 5881 was 4272, checked in by bastiK, 13 years ago |
mapcss: proper support for scaled icons (fixes #6560)
|
-
Property svn:eol-style
set to
native
|
File size:
1.2 KB
|
Rev | Line | |
---|
[3719] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[429] | 2 | package org.openstreetmap.josm.tools;
|
---|
| 3 | import java.util.ArrayList;
|
---|
| 4 |
|
---|
| 5 | /**
|
---|
| 6 | * A pair.
|
---|
| 7 | */
|
---|
| 8 | public final class Pair<A,B> {
|
---|
[1169] | 9 | public A a;
|
---|
| 10 | public B b;
|
---|
[429] | 11 |
|
---|
[1169] | 12 | public Pair(A a, B b) {
|
---|
| 13 | this.a = a;
|
---|
| 14 | this.b = b;
|
---|
| 15 | }
|
---|
[429] | 16 |
|
---|
[1169] | 17 | @Override public int hashCode() {
|
---|
[2910] | 18 | return a.hashCode() + b.hashCode();
|
---|
[1169] | 19 | }
|
---|
[429] | 20 |
|
---|
[2626] | 21 | @Override public boolean equals(Object other) {
|
---|
| 22 | if (other instanceof Pair<?, ?>) {
|
---|
| 23 | Pair<?, ?> o = (Pair<?, ?>)other;
|
---|
| 24 | return a.equals(o.a) && b.equals(o.b);
|
---|
| 25 | } else
|
---|
| 26 | return false;
|
---|
[1169] | 27 | }
|
---|
[429] | 28 |
|
---|
[1169] | 29 | public static <T> ArrayList<T> toArrayList(Pair<T, T> p) {
|
---|
| 30 | ArrayList<T> l = new ArrayList<T>(2);
|
---|
| 31 | l.add(p.a);
|
---|
| 32 | l.add(p.b);
|
---|
| 33 | return l;
|
---|
| 34 | }
|
---|
[429] | 35 |
|
---|
[1169] | 36 | public static <T> Pair<T,T> sort(Pair<T,T> p) {
|
---|
| 37 | if (p.b.hashCode() < p.a.hashCode()) {
|
---|
| 38 | T tmp = p.a;
|
---|
| 39 | p.a = p.b;
|
---|
| 40 | p.b = tmp;
|
---|
| 41 | }
|
---|
| 42 | return p;
|
---|
| 43 | }
|
---|
[3560] | 44 |
|
---|
| 45 | @Override
|
---|
| 46 | public String toString() {
|
---|
| 47 | return "<"+a+","+b+">";
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[4272] | 50 | /* convenience constructor method */
|
---|
| 51 | public static <U,V> Pair<U,V> create(U u, V v) {
|
---|
| 52 | return new Pair<U,V>(u,v);
|
---|
| 53 | }
|
---|
[429] | 54 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.