本文整理汇总了Java中java.util.List.lastIndexOf方法的典型用法代码示例。如果您正苦于以下问题:Java List.lastIndexOf方法的具体用法?Java List.lastIndexOf怎么用?Java List.lastIndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.List
的用法示例。
在下文中一共展示了List.lastIndexOf方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLastIndexOf2
import java.util.List; //导入方法依赖的package包/类
@Test
public void testLastIndexOf2() {
List<Integer> list = redisson.getList("list");
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(0);
list.add(7);
list.add(8);
list.add(0);
list.add(10);
int index = list.lastIndexOf(3);
Assert.assertEquals(2, index);
}
示例2: testLastIndexOf1
import java.util.List; //导入方法依赖的package包/类
@Test
public void testLastIndexOf1() {
List<Integer> list = redisson.getList("list");
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(3);
list.add(7);
list.add(8);
list.add(0);
list.add(10);
int index = list.lastIndexOf(3);
Assert.assertEquals(5, index);
}
示例3: testLastIndexOf
import java.util.List; //导入方法依赖的package包/类
@Test
public void testLastIndexOf() {
List<Integer> list = redisson.getList("list");
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);
list.add(3);
list.add(7);
list.add(8);
list.add(3);
list.add(10);
int index = list.lastIndexOf(3);
Assert.assertEquals(8, index);
}
示例4: testModLastIndexOf
import java.util.List; //导入方法依赖的package包/类
@Test(dataProvider = "modifiable",
expectedExceptions = ConcurrentModificationException.class)
public void testModLastIndexOf(List<Integer> list, int from, int to) {
List<Integer> subList = list.subList(from, to);
list.add(42);
subList.lastIndexOf(42);
}
示例5: performNextItemBy
import java.util.List; //导入方法依赖的package包/类
private void performNextItemBy(Button cell) {
final List<Button> buttons = streamOfShownItems()
.collect(Collectors.<Button>toList());
final int nextIndex = buttons.lastIndexOf(cell) + 1;
final int clickIndex = Math.min(nextIndex, buttons.size() - 1);
performItemSelected(buttons.get(clickIndex));
}
示例6: getRoutingProbability
import java.util.List; //导入方法依赖的package包/类
/**
* This method will return a reachability vector for given station and given class
* @param stationKey search's key for given station
* @param classKey search's key for given class
* @param model model data structure
* @param stations vector with ordered station keys (the same order is used in output array)
* @param warnings vector Vector to store warnings found during computation
* @return an array with probability to reach each other station starting from given station
*/
private static double[] getRoutingProbability(Object stationKey, Object classKey, CommonModel model, List<Object> stations, List<String> warnings) {
double[] p = new double[stations.size()];
RoutingStrategy strategy = (RoutingStrategy) model.getRoutingStrategy(stationKey, classKey);
if (strategy instanceof ProbabilityRouting && !model.getStationType(stationKey).equals(CommonConstants.STATION_TYPE_FORK)) {
Map<Object, Double> routingMap = strategy.getValues();
Iterator<Object> it = routingMap.keySet().iterator();
while (it.hasNext()) {
Object dest = it.next();
if (stations.lastIndexOf(dest) >= 0) {
p[stations.lastIndexOf(dest)] = (routingMap.get(dest)).doubleValue();
}
}
} else {
if (model.getStationType(stationKey).equals(CommonConstants.STATION_TYPE_FORK)) {
warnings.add("Fork-Join are not supported in JMVA. They are considered as routers.");
} else if (!(strategy instanceof RandomRouting)) {
warnings.add("\"" + strategy.getName() + "\" routing strategy in " + model.getClassName(classKey) + " for "
+ model.getStationName(stationKey) + " is not allowed. This was considered as RandomRouting");
}
Vector<Object> links = model.getForwardConnections(stationKey);
int linksNum = links.size();
// Now ignores sinks for closed classes
if (model.getClassType(classKey) == CommonConstants.CLASS_TYPE_CLOSED) {
for (int i = 0; i < links.size(); i++) {
if (model.getStationType(links.get(i)).equals(CommonConstants.STATION_TYPE_SINK)) {
linksNum--;
}
}
}
double weight = 1.0 / linksNum;
for (int i = 0; i < links.size(); i++) {
if (stations.contains(links.get(i))) {
p[stations.lastIndexOf(links.get(i))] = weight;
}
}
}
return p;
}
示例7: getRoutingProbability
import java.util.List; //导入方法依赖的package包/类
/**
* This method will return a reachability vector for given station and given class
* @param stationKey search's key for given station
* @param classKey search's key for given class
* @param model model data structure
* @param stations vector with ordered station keys (the same order is used in output array)
* @param warnings vector Vector to store warnings found during computation
* @return an array with probability to reach each other station starting from given station
*/
private static double[] getRoutingProbability(Object stationKey, Object classKey, CommonModel model, List<Object> stations, List<String> warnings) {
double[] p = new double[stations.size()];
RoutingStrategy strategy = (RoutingStrategy) model.getRoutingStrategy(stationKey, classKey);
if (strategy instanceof ProbabilityRouting && !model.getStationType(stationKey).equals(CommonConstants.STATION_TYPE_FORK)) {
Map routingMap = strategy.getValues();
Iterator it = routingMap.keySet().iterator();
while (it.hasNext()) {
Object dest = it.next();
if (stations.lastIndexOf(dest) >= 0) {
p[stations.lastIndexOf(dest)] = ((Double) routingMap.get(dest)).doubleValue();
}
}
} else {
if (model.getStationType(stationKey).equals(CommonConstants.STATION_TYPE_FORK)) {
warnings.add("Fork-Join are not supported in JMVA. They are considered as routers.");
} else if (!(strategy instanceof RandomRouting)) {
warnings.add("\"" + strategy.getName() + "\" routing strategy in " + model.getClassName(classKey) + " for "
+ model.getStationName(stationKey) + " is not allowed. This was considered as RandomRouting");
}
Vector<Object> links = model.getForwardConnections(stationKey);
int linksNum = links.size();
// Now ignores sinks for closed classes
if (model.getClassType(classKey) == CommonConstants.CLASS_TYPE_CLOSED) {
for (int i = 0; i < links.size(); i++) {
if (model.getStationType(links.get(i)).equals(CommonConstants.STATION_TYPE_SINK)) {
linksNum--;
}
}
}
double weight = 1.0 / linksNum;
for (int i = 0; i < links.size(); i++) {
if (stations.contains(links.get(i))) {
p[stations.lastIndexOf(links.get(i))] = weight;
}
}
}
return p;
}
示例8: searchByClosest2
import java.util.List; //导入方法依赖的package包/类
public List<AbstractNodeLoc> searchByClosest2(GeoNode start, GeoNode end)
{
// Always continues checking from the closest to target non-blocked
// node from to_visit list. There's extra length in path if needed
// to go backwards/sideways but when moving generally forwards, this is extra fast
// and accurate. And can reach insane distances (try it with 800 nodes..).
// Minimum required node count would be around 300-400.
// Generally returns a bit (only a bit) more intelligent looking routes than
// the basic version. Not a true distance image (which would increase CPU
// load) level of intelligence though.
// List of Visited Nodes
final List<GeoNode> visited = new ArrayList<>(550);
// List of Nodes to Visit
final LinkedList<GeoNode> to_visit = new LinkedList<>();
to_visit.add(start);
final int targetX = end.getLoc().getNodeX();
final int targetY = end.getLoc().getNodeY();
int dx, dy;
boolean added;
int i = 0;
while (i < 550)
{
GeoNode node;
try
{
node = to_visit.removeFirst();
}
catch (Exception e)
{
// No Path found
return null;
}
if (node.equals(end))
{
return constructPath2(node);
}
i++;
visited.add(node);
node.attachNeighbors();
final GeoNode[] neighbors = node.getNeighbors();
if (neighbors == null)
{
continue;
}
for (GeoNode n : neighbors)
{
if ((visited.lastIndexOf(n) == -1) && !to_visit.contains(n))
{
added = false;
n.setParent(node);
dx = targetX - n.getLoc().getNodeX();
dy = targetY - n.getLoc().getNodeY();
n.setCost((dx * dx) + (dy * dy));
for (int index = 0; index < to_visit.size(); index++)
{
// supposed to find it quite early..
if (to_visit.get(index).getCost() > n.getCost())
{
to_visit.add(index, n);
added = true;
break;
}
}
if (!added)
{
to_visit.addLast(n);
}
}
}
}
// No Path found
return null;
}
示例9: lastIndexOf
import java.util.List; //导入方法依赖的package包/类
@Override
public int lastIndexOf(Object o) {
final List<V> list = ListUtils.emptyIfNull(getMapping());
return list.lastIndexOf(o);
}