Last change
on this file since 3711 was 3711, checked in by bastiK, 14 years ago |
minor change needed for terracer plugin
|
-
Property svn:eol-style
set to
native
|
File size:
926 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | public class Utils {
|
---|
5 |
|
---|
6 | public static <T> boolean exists(Iterable<? extends T> coll, Predicate<? super T> pred) {
|
---|
7 | for (T el : coll) {
|
---|
8 | if (pred.evaluate(el))
|
---|
9 | return true;
|
---|
10 | }
|
---|
11 | return false;
|
---|
12 | }
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Get minimum of 3 values
|
---|
16 | */
|
---|
17 | public static int min(int a, int b, int c) {
|
---|
18 | if (b < c) {
|
---|
19 | if (a < b)
|
---|
20 | return a;
|
---|
21 | return b;
|
---|
22 | } else {
|
---|
23 | if (a < c) {
|
---|
24 | return a;
|
---|
25 | }
|
---|
26 | return c;
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * return the modulus in the range [0, n)
|
---|
32 | */
|
---|
33 | public static int mod(int a, int n) {
|
---|
34 | if (n <= 0)
|
---|
35 | throw new IllegalArgumentException();
|
---|
36 | int res = a % n;
|
---|
37 | if (res < 0) {
|
---|
38 | res += n;
|
---|
39 | }
|
---|
40 | return res;
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.