本文整理汇总了Java中java.util.LinkedList.clear方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedList.clear方法的具体用法?Java LinkedList.clear怎么用?Java LinkedList.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.LinkedList
的用法示例。
在下文中一共展示了LinkedList.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBook
import java.util.LinkedList; //导入方法依赖的package包/类
@RequestMapping(value = "/createBook", method = RequestMethod.POST)
public String createBook(@RequestParam("billingAddress") Long billingAddressId,
@RequestParam("shippingAddress") Long shippingAddressId, @RequestParam("couponCodeId") Long couponCodeId,
Model model, HttpServletRequest request) {
Iterable<Book> books = booksService.findAll();
LinkedList<Book> chosenBooks = new LinkedList<Book>();
chosenBooks.clear();
for (Book x : books)
if (request.getParameter(x.getName()) != null)
chosenBooks.add(x);
String[] books1 = new String[chosenBooks.size()];
int j = 0;
for (int i = 0; i < books1.length; i++)
books1[j++] = chosenBooks.get(i).getName();
addNeedObjects(model, couponCodeId, billingAddressId, shippingAddressId, books1);
return "administratorSite/ordersManager/create";
}
示例2: close
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Closes *ALL* the player's Guis, clearing his stack histories
*
* @param player the player
*/
public void close(Player player) {
if (called) return;
called = true;
try {
LinkedList<Gui> g = histories.remove(player);
if (g == null || g.isEmpty())
return;
Gui oldGui = g.peek();
GuiCloseEvent e = new GuiCloseEvent(player, oldGui);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled()) {
histories.put(player, g);
return;
}
oldGui.onClose(player);
player.closeInventory();
g.clear();
} finally {
called = false;
}
}
示例3: setOptionsShouldKeepSameInstance
import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void setOptionsShouldKeepSameInstance() throws Exception {
Option option = mock(Option.class);
ArrayList aggregate = new ArrayList<String>();
aggregate.add("option");
when(option.getAggregate()).thenReturn(aggregate);
when(option.getHelp()).thenReturn("help text");
LinkedList<Option> options = new LinkedList<>();
options.add(option);
this.emptyOptionParser.setOptions(options);
assertThat(this.emptyOptionParser.getOptions()).isSameAs(options);
assertThat(this.emptyOptionParser.getOptions()).hasSize(1);
options.clear();
assertThat(options).hasSize(0);
assertThat(this.emptyOptionParser.getOptions()).hasSize(0);
}
示例4: getLatestImages
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* @return the image files that have the most recent associated
* transaction IDs. If there are multiple storage directories which
* contain equal images, we'll return them all.
*
* @throws FileNotFoundException if not images are found.
*/
@Override
List<FSImageFile> getLatestImages() throws IOException {
LinkedList<FSImageFile> ret = new LinkedList<FSImageFile>();
for (FSImageFile img : foundImages) {
if (ret.isEmpty()) {
ret.add(img);
} else {
FSImageFile cur = ret.getFirst();
if (cur.txId == img.txId) {
ret.add(img);
} else if (cur.txId < img.txId) {
ret.clear();
ret.add(img);
}
}
}
if (ret.isEmpty()) {
throw new FileNotFoundException("No valid image files found");
}
return ret;
}
示例5: remove
import java.util.LinkedList; //导入方法依赖的package包/类
public synchronized void remove (String pkey, AuthCacheValue entry) {
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
if (list == null) {
return;
}
if (entry == null) {
list.clear();
return;
}
ListIterator<AuthCacheValue> iter = list.listIterator ();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (entry.equals(inf)) {
iter.remove ();
}
}
}
示例6: createBook
import java.util.LinkedList; //导入方法依赖的package包/类
@RequestMapping(value = "update/createBooks", method = RequestMethod.POST)
public String createBook(@RequestParam("orderId") Long id, Model model, HttpServletRequest request) {
Iterable<Book> allBooks = booksService.findAll();
LinkedList<Book> chosenBooks = new LinkedList<Book>();
chosenBooks.clear();
for (Book x : allBooks)
if (request.getParameter(x.getName()) != null)
chosenBooks.add(x);
Order order = ordersService.findOne(id);
order.setBooks(chosenBooks);
ordersService.save(order);
return updateOne(id, model);
}
示例7: open
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Opens a Gui to a player, adding it to the stack. If the closeOthers parameter is specified it will removeHotbar the stack first
*
* @param player the player that is opening the api
* @param gui the gui to be opened
* @param closeOthers if give to true the GUI histories would be cleaned
*/
public void open(Player player, Gui gui, boolean closeOthers) {
if (called) return;
called = true;
try {
LinkedList<Gui> g = getOrCreate(player);
Gui oldGui = g.peek();
GuiOpenEvent e = new GuiOpenEvent(player, gui, oldGui);
e.setCloseOthers(closeOthers);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled()) {
if (g.isEmpty())
histories.remove(player);
return;
}
closeOthers = e.isCloseOthers();
if (oldGui != null)
oldGui.onClose(player);
if (closeOthers)
g.clear();
gui.onOpen(player);
gui.show(player);
g.push(gui);
} finally {
called = false;
}
}
示例8: testClear
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* clear removes all elements
*/
public void testClear() {
LinkedList q = populatedQueue(SIZE);
q.clear();
assertTrue(q.isEmpty());
assertEquals(0, q.size());
assertTrue(q.add(new Integer(1)));
assertFalse(q.isEmpty());
q.clear();
assertTrue(q.isEmpty());
}
示例9: processTimerList
import java.util.LinkedList; //导入方法依赖的package包/类
private void processTimerList( LinkedList<TimerWheelTimer> pList ){
ListIterator<TimerWheelTimer> ExpiredTimer = pList.listIterator();
while (ExpiredTimer.hasNext()){
try{
ExpiredTimer.next().getExpiryFunction().invoke(expiryObject, expiryData);
ExpiredTimer.remove();
numberOfTimers--;
}catch(Exception e){
e.printStackTrace();
}
}
pList.clear();
}
示例10: transferThroughList
import java.util.LinkedList; //导入方法依赖的package包/类
private String transferThroughList(String in, int index) {
LinkedList<String> list = new LinkedList<String>();
list.add(System.getenv("")); // taints the list
list.clear(); // makes the list safe again
list.add(1, "xx");
list.addFirst(in); // can taint the list
list.addLast("yy");
list.push(in);
return list.element() + list.get(index) + list.getFirst() + list.getLast()
+ list.peek() + list.peekFirst() + list.peekLast() + list.poll()
+ list.pollFirst() + list.pollLast() + list.pop() + list.remove()
+ list.remove(index) + list.removeFirst() + list.removeLast()
+ list.set(index, "safe") + list.toString();
}
示例11: setDefaultPort
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Set the port of the (shared) default endpoint object.
* When first created, it contains port 0 because the transport
* hasn't tried to listen to get assigned a port, or if listening
* failed, a port hasn't been assigned from the server.
*/
static void setDefaultPort(int port, RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
{
TCPEndpoint endpointKey = new TCPEndpoint(null, 0, csf, ssf);
synchronized (localEndpoints) {
LinkedList<TCPEndpoint> epList = localEndpoints.get(endpointKey);
synchronized (epList) {
int size = epList.size();
TCPEndpoint lastEp = epList.getLast();
for (TCPEndpoint ep : epList) {
ep.port = port;
}
if (size > 1) {
/*
* Remove all but the last element of the list
* (which contains the most recent hostname).
*/
epList.clear();
epList.add(lastEp);
}
}
/*
* Allow future exports to use the actual bound port
* explicitly (see 6269166).
*/
TCPEndpoint newEndpointKey = new TCPEndpoint(null, port, csf, ssf);
localEndpoints.put(newEndpointKey, epList);
if (TCPTransport.tcpLog.isLoggable(Log.BRIEF)) {
TCPTransport.tcpLog.log(Log.BRIEF,
"default port for server socket factory " + ssf +
" and client socket factory " + csf +
" set to " + port);
}
}
}
示例12: update
import java.util.LinkedList; //导入方法依赖的package包/类
private void update (LinkedList<String> toUpdate, List<String> newValues) {
toUpdate.clear();
toUpdate.addAll(newValues);
}
示例13: heartbeatCheck
import java.util.LinkedList; //导入方法依赖的package包/类
@Override
public void heartbeatCheck(long timeout) {
// 心跳检测, 超时抛弃
// --------------------------------------------------------------------------
long heartbeatTime = System.currentTimeMillis() - timeout;
long closeTime = System.currentTimeMillis() - timeout * 2;
LinkedList<RedisBackendConnection> heartBeatCons = getNeedHeartbeatCons( physicalNode.conQueue.getCons(), heartbeatTime, closeTime);
for (RedisBackendConnection conn : heartBeatCons) {
conHeartBeatHanler.doHeartBeat(conn, PING );
}
heartBeatCons.clear();
conHeartBeatHanler.abandTimeoutConns();
// 连接池 动态调整逻辑
// -------------------------------------------------------------------------------
int idleCons = this.getIdleCount();
int activeCons = this.getActiveCount();
int minCons = poolCfg.getMinCon();
int maxCons = poolCfg.getMaxCon();
if ( LOGGER.isDebugEnabled() ) {
LOGGER.debug( "Sthandalone heartbeat: host={}, idle={}, active={}, min={}, max={}, lasttime={}",
new Object[] { physicalNode.getHost() + ":" + physicalNode.getPort(),
idleCons, activeCons, minCons, maxCons, System.currentTimeMillis() } );
}
if ( idleCons > minCons ) {
if ( idleCons < activeCons ) {
return;
}
//闲置太多
closeByIdleMany(this.physicalNode, idleCons - minCons );
} else if ( idleCons < minCons ) {
if ( idleCons > ( minCons * 0.5 ) ) {
return;
}
//闲置太少
if ( (idleCons + activeCons) < maxCons ) {
int createCount = (int)Math.ceil( (minCons - idleCons) / 3F );
createByIdleLitte(this.physicalNode, idleCons, createCount);
}
}
// if ( ( (idleCons + activeCons) < maxCons ) && idleCons < minCons ) {
// //闲置太少
// int createCount = (int)Math.ceil( (minCons - idleCons) / 3F );
// createByIdleLitte(this.physicalNode, idleCons, createCount);
//
// } else if ( idleCons > minCons ) {
// //闲置太多
// closeByIdleMany(this.physicalNode, idleCons - minCons );
// }
}
示例14: imageToText
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Converts a {@link java.awt.image.BufferedImage} to a multi-line text message, using {@link #COLOR_MAP}.
*
* @return A {@link java.lang.String[]} containing the message
*/
public static String[] imageToText(BufferedImage image, boolean trim) {
int height = Preconditions.checkNotNull(image, "Image").getHeight();
int width = image.getWidth();
String[][] message = new String[height][width];
LinkedList<Integer> pendingAlpha = new LinkedList<>();
for (int y = 0; y < height; y++) {
boolean fillAlpha = !trim;
boolean left = false;
for (int x = 0; x < width; x++) {
Color color = new Color(image.getRGB(x, y), true);
if (trim) {
if (color.getAlpha() < 1) {
pendingAlpha.add(x);
left = (left || x == 0);
} else {
if (!left) {
applyPendingAlpha(pendingAlpha, message[y]);
} else {
pendingAlpha.clear();
left = false;
}
}
}
ChatColor minecraftColor = rgbToMinecraft(closestColorMatch(color, COLOR_MAP.keySet()));
message[y][x] = minecraftColor == null ? (fillAlpha ? ALPHA_FILLER_CONTENT : "") : minecraftColor.toString() + PIXEL_CHAR;
}
if (!trim) {
applyPendingAlpha(pendingAlpha, message[y]);
}
}
String[] messageFinal = new String[height];
for (int y = 0; y < height; y++) {
messageFinal[y] = StringUtils.join(message[y]);
}
return messageFinal;
}
示例15: clearRuntimeEvents
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Clear the runtime event queue
* @param self self reference
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static void clearRuntimeEvents(final Object self) {
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self);
q.clear();
}