/*
* Vitry, copyright (C) Hans Hoglund 2011
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* See COPYING.txt for details.
*/
package vitry.runtime.util;
import java.util.Iterator;
public class Arrays
{
private Arrays() {
}
public static Object[] conc(Object[] a, Object... b)
{
Object[] res = new Object[a.length + b.length];
System.arraycopy(a, 0, res, 0, a.length);
System.arraycopy(b, 0, res, a.length, b.length);
return res;
}
public static int linearSearch(Object[] a, Object key)
{
for (int i = 0; i < a.length; i++)
{
if (a[i].equals(key))
return i;
}
return -1;
}
public static <T> Iterable<T> asIterable(final T[] a)
{
return new Iterable<T>()
{
public Iterator<T> iterator()
{
return new ArrayIterator<T>(a, 0);
}
};
}
}