Here you can find the source of arrayLookup(int[] ar, int keystart, int keyend, int forbidden)
Parameter | Description |
---|---|
ar | Array to perform lookup in |
keystart | lower limit of range, range includes this value |
keyend | high limit of range, range excludes this value |
forbidden | a value that may not be looked up. |
public static int arrayLookup(int[] ar, int keystart, int keyend, int forbidden)
//package com.java2s; /*/*from w ww . ja v a 2 s. c om*/ * Copyright 2005--2008 Helsinki Institute for Information Technology * * This file is a part of Fuego middleware. Fuego middleware is free * software; you can redistribute it and/or modify it under the terms * of the MIT license, included as the file MIT-LICENSE in the Fuego * middleware source distribution. If you did not receive the MIT * license with the distribution, write to the Fuego Core project at * fuego-core-users@googlegroups.com. */ public class Main { /** Find first entry in integer array, whose value is in a given range. * @param ar Array to perform lookup in * @param keystart lower limit of range, range includes this value * @param keyend high limit of range, range excludes this value * @param forbidden a value that may not be looked up. * @return index of entry in array, -1 if no entry found */ public static int arrayLookup(int[] ar, int keystart, int keyend, int forbidden) { for (int i = 0; ar != null && i < ar.length; i++) if (ar[i] >= keystart && ar[i] < keyend && ar[i] != forbidden) return i; return -1; } /** Find first entry in integer array, whose value is in a given range. * @param ar Array to perform lookup in * @param keystart lower limit of range, range includes this value * @param keyend high limit of range, range excludes this value * @return index of entry in array, -1 if no entry found */ public static int arrayLookup(int[] ar, int keystart, int keyend) { for (int i = 0; ar != null && i < ar.length; i++) if (ar[i] >= keystart && ar[i] < keyend) return i; return -1; } }