|
LazyLib | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.lazywizard.lazylib.CollectionUtils
public class CollectionUtils
Contains methods for working with Collections.
Nested Class Summary | |
---|---|
static class |
CollectionUtils.SortEntitiesByDistance
A Comparator that sorts CombatEntityAPI s by distance from a Vector2f . |
static class |
CollectionUtils.SortObjectivesByDistance
A Comparator that sorts BattleObjectiveAPI s by distance from a Vector2f . |
static class |
CollectionUtils.SortTokensByDistance
A Comparator that sorts SectorEntityToken s by distance from a Vector2f . |
Method Summary | ||
---|---|---|
static java.lang.String |
implode(java.util.Collection<java.lang.String> toImplode)
Creates a comma-separated String from a Collection of String s. |
|
static java.lang.String |
implode(java.util.Collection<java.lang.String> toImplode,
java.lang.String separator)
Combines and separates a Collection of String s. |
|
static
|
weightedRandom(java.util.Map<T,java.lang.Float> pickFrom)
Returns a single item chosen via a weighted random from a Map . |
|
static
|
weightedRandom(java.util.Map<T,java.lang.Float> pickFrom,
int numToPick)
Returns a List of items chosen via a weighted random from a Map . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> java.util.List<T> weightedRandom(java.util.Map<T,java.lang.Float> pickFrom, int numToPick)
List
of items chosen via a weighted random from a Map
.
pickFrom
- A Map
of items to choose from.
The value is the weight, in float form, of that item being chosen.numToPick
- How many items to choose from pickFrom
's keys.
List
containing the subset of pickFrom
chosen.public static <T> T weightedRandom(java.util.Map<T,java.lang.Float> pickFrom)
Map
.
pickFrom
- A Map
of items to choose from.
The value is the weight, in float form, of that item being chosen.
pickFrom
's keys.public static java.lang.String implode(java.util.Collection<java.lang.String> toImplode, java.lang.String separator)
Collection
of String
s. Useful for comma-separated lists.
toImplode
- A Collection
of String
s to be combined.separator
- The separator character to split toImplode
with.
String
consisting of toImplode
's values
separated with separator
.public static java.lang.String implode(java.util.Collection<java.lang.String> toImplode)
String
from a Collection
of String
s.
toImplode
- A Collection
of String
s to be combined.
String
consisting of toImplode
's values
separated with commas.implode(java.util.Collection, java.lang.String)
|
LazyLib | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |