That's already a T, so we don't need to cast it.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2908 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001-2010 Michael Bayne, et al.
|
// Copyright (C) 2001-2010 Michael Bayne, et al.
|
||||||
//
|
//
|
||||||
// This library is free software; you can redistribute it and/or modify it
|
// This library is free software; you can redistribute it and/or modify it
|
||||||
// under the terms of the GNU Lesser General Public License as published
|
// under the terms of the GNU Lesser General Public License as published
|
||||||
// by the Free Software Foundation; either version 2.1 of the License, or
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
@@ -99,7 +99,7 @@ public class Randoms
|
|||||||
{
|
{
|
||||||
return _r.nextFloat() * high;
|
return _r.nextFloat() * high;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pseudorandom, uniformly distributed <code>float</code> value between
|
* Returns a pseudorandom, uniformly distributed <code>float</code> value between
|
||||||
* <code>low</code> (inclusive) and <code>high</code> (exclusive).
|
* <code>low</code> (inclusive) and <code>high</code> (exclusive).
|
||||||
@@ -223,9 +223,8 @@ public class Randoms
|
|||||||
/**
|
/**
|
||||||
* Shared code for pick and pluck.
|
* Shared code for pick and pluck.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected <T> T pickPluck (Iterable<? extends T> iterable, T ifEmpty, boolean remove)
|
protected <T> T pickPluck (Iterable<? extends T> iterable, T ifEmpty, boolean remove)
|
||||||
{
|
{
|
||||||
if (iterable instanceof Collection) {
|
if (iterable instanceof Collection) {
|
||||||
// optimized path for Collection
|
// optimized path for Collection
|
||||||
Collection<? extends T> coll = (Collection<? extends T>)iterable;
|
Collection<? extends T> coll = (Collection<? extends T>)iterable;
|
||||||
@@ -237,7 +236,7 @@ public class Randoms
|
|||||||
// extra-special optimized path for Lists
|
// extra-special optimized path for Lists
|
||||||
List<? extends T> list = (List<? extends T>)coll;
|
List<? extends T> list = (List<? extends T>)coll;
|
||||||
int idx = _r.nextInt(size);
|
int idx = _r.nextInt(size);
|
||||||
return (T)(remove ? list.remove(idx) : list.get(idx));
|
return remove ? list.remove(idx) : list.get(idx);
|
||||||
}
|
}
|
||||||
// for other Collections, we must iterate
|
// for other Collections, we must iterate
|
||||||
Iterator<? extends T> it = coll.iterator();
|
Iterator<? extends T> it = coll.iterator();
|
||||||
|
|||||||
Reference in New Issue
Block a user