当前位置: 首页>>代码示例>>Java>>正文


Java LinkedList.addLast方法代码示例

本文整理汇总了Java中java.util.LinkedList.addLast方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedList.addLast方法的具体用法?Java LinkedList.addLast怎么用?Java LinkedList.addLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.LinkedList的用法示例。


在下文中一共展示了LinkedList.addLast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: push

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * FIFO to calculate the correct purchase amount.
 * purchases are added to the head of a queue. sales are deducted from the tail of purchases.
 *
 * @param order the order to process into the queue
 * @param fifo the queue
 */
private void push(OrderData order, LinkedList<OrderData>fifo) {
    if(order.getCategory().equals(PurchaseCategory.PURCHASE.code)) {
        fifo.addLast(order);
    } else {
        double deduct = order.getAmount();
        do {
            if( fifo.isEmpty() ) {deduct = 0; continue; }

            OrderData first = fifo.getFirst();
            if(first.getAmount() <= deduct) {
                deduct-=first.getAmount();
                fifo.removeFirst();
            }
            else {
                first.setAmount(first.getAmount()-deduct);
                deduct = 0;
            }
        } while(deduct > 0);
    }
}
 
开发者ID:asciimo71,项目名称:hashnest,代码行数:28,代码来源:StatisticService.java

示例2: getAllEntitiesCarriedBySimEventsAtCurrentClockNoTrash

import java.util.LinkedList; //导入方法依赖的package包/类
public static LinkedList<Entity> getAllEntitiesCarriedBySimEventsAtCurrentClockNoTrash(){
  LinkedList<Entity> returnList = new LinkedList<Entity>();
  LinkedList<Integer> entityTags = new LinkedList<Integer>();
  
  Iterator<SimEvent> itrEvents = ((HybridEventQueue)SimSystem.getFutureQueue()).getCurrentList().iterator();
  while(itrEvents.hasNext()){
    SimEvent anEvent = itrEvents.next();
    if(anEvent.eventTime() == SimSystem.clock()){
      Job job = (Job)anEvent.getData();
      
      if(job == null) 
      	continue;
      
      Entity entity = job.qnactrEntity;
      if(!entityTags.contains(entity.Tag) && !entity.Trash){
        entityTags.addLast(entity.Tag);
        returnList.addLast(entity);
      }
    }
    
  }
  
  return returnList;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:25,代码来源:QnactrSimulation.java

示例3: discoverDirectory

import java.util.LinkedList; //导入方法依赖的package包/类
public static Map<FileType, List<File>> discoverDirectory(File directory) {
    Map<FileType, List<File>> candidates = new HashMap<>();
    for (FileType type : FileType.values()) {
        candidates.put(type, Lists.newLinkedList());
    }
    LinkedList<File> directories = Lists.newLinkedList();
    directories.add(directory);
    while (!directories.isEmpty()) {
        File dir = directories.remove(0);
        for (File f : dir.listFiles()) {
            if(f.isDirectory()) {
                directories.addLast(f);
            } else {
                //I am *not* taking chances with this ordering
                if(FileType.VARIABLES.accepts(f.getName())) {
                    candidates.get(FileType.VARIABLES).add(f);
                } else if(FileType.MACHINE.accepts(f.getName())) {
                    candidates.get(FileType.MACHINE).add(f);
                }
            }
        }
    }
    return candidates;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:25,代码来源:MachineLoader.java

示例4: objectToCollection

import java.util.LinkedList; //导入方法依赖的package包/类
protected static final Collection<?> objectToCollection(Object object) {
	Collection<?> collection = null;
	if (object != null) {
		if (object instanceof Collection) {
			collection = (Collection<?>) object;
		} else if (object instanceof Map) {
			collection = ((Map<?, ?>) object).values();
		} else if (object.getClass().isArray()) {
			LinkedList<Object> list = new LinkedList<Object>();
			int len = Array.getLength(object);
			for (int i = 0; i < len; i++) {
				list.addLast(Array.get(object, i));
			}
			collection = list;
		} else {
			collection = Collections.singleton(object);
		}
	}
	return collection;
}
 
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:21,代码来源:CsvOpenCSV.java

示例5: readServerMessages

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Reads lines from the input stream of the socket.
 * 
 * @return LinkedList&ltString&gt: The lines read.
 */
public LinkedList<String> readServerMessages() {

	String line = null;
	LinkedList<String> answer = new LinkedList<>();

	try {
		while (this.reader.ready()) {
			line = this.reader.readLine();
			answer.addLast(line);

			this.addToProtocol("SERVER: " + line);

			if (line.startsWith("PING")) {
				pingRespond();
			}
		}

	} catch (IOException e) {
		System.err.println("An I/O Exception occured while trying to read from the input stream.");

	}

	return answer;
}
 
开发者ID:Ativelox,项目名称:TwitchBot,代码行数:30,代码来源:IRCClient.java

示例6: loadWS353Data

import java.util.LinkedList; //导入方法依赖的package包/类
public static LinkedList<WS353Node> loadWS353Data (String filePath) {
	LinkedList<WS353Node> list = new LinkedList<>();
	try {
		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(new ClassPathResource(filePath).getFile())));
		String line;
		while ((line = reader.readLine()) != null) {
			String[] segments = line.trim().split("\t");
			WS353Node node = new WS353Node(segments[0], segments[1], Double.parseDouble(segments[2]));
			list.addLast(node);
		}
		reader.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return list;
}
 
开发者ID:IsaacChanghau,项目名称:Word2VecfJava,代码行数:17,代码来源:Word2VecWS353Test.java

示例7: main

import java.util.LinkedList; //导入方法依赖的package包/类
public static void main(String[] args) 
{
	LinkedList dogs = new LinkedList();
	Dog dog1 = new Dog("aa", "bb");
	Dog dog2 = new Dog("cc", "dd");
	Dog dog3 = new Dog("ee", "ff");
	Dog dog4 = new Dog("gg", "hh");

	dogs.add(dog1);
	dogs.add(dog2);
	dogs.addFirst(dog3);
	dogs.addLast(dog4);

	Dog dogFirst = (Dog) dogs.getFirst();
	LOGGER.info("第一条狗狗的信息是{}", dogFirst.getName());

	Dog dogLast = (Dog) dogs.getLast();
	LOGGER.info("最后一条狗狗的信息是{}", dogLast.getName());

	dogs.removeFirst();
	dogs.removeLast();

	for (Object element : dogs)
	{
		LOGGER.info(element);
	}
}
 
开发者ID:JAVA201708,项目名称:Homework,代码行数:28,代码来源:LinkedListTest.java

示例8: getMaximallySpecificMethods

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Given a list of methods, returns a list of maximally specific methods, applying language-runtime specific
 * conversion preferences.
 *
 * @param methods the list of methods
 * @param varArgs whether to assume the methods are varargs
 * @param argTypes concrete argument types for the invocation
 * @return the list of maximally specific methods.
 */
private static <T> List<T> getMaximallySpecificMethods(final List<T> methods, final boolean varArgs,
        final Class<?>[] argTypes, final LinkerServices ls, final MethodTypeGetter<T> methodTypeGetter) {
    if(methods.size() < 2) {
        return methods;
    }
    final LinkedList<T> maximals = new LinkedList<>();
    for(final T m: methods) {
        final MethodType methodType = methodTypeGetter.getMethodType(m);
        boolean lessSpecific = false;
        for(final Iterator<T> maximal = maximals.iterator(); maximal.hasNext();) {
            final T max = maximal.next();
            switch(isMoreSpecific(methodType, methodTypeGetter.getMethodType(max), varArgs, argTypes, ls)) {
                case TYPE_1_BETTER: {
                    maximal.remove();
                    break;
                }
                case TYPE_2_BETTER: {
                    lessSpecific = true;
                    break;
                }
                case INDETERMINATE: {
                    // do nothing
                    break;
                }
                default: {
                    throw new AssertionError();
                }
            }
        }
        if(!lessSpecific) {
            maximals.addLast(m);
        }
    }
    return maximals;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:MaximallySpecific.java

示例9: writeToMapper

import java.util.LinkedList; //导入方法依赖的package包/类
protected static final void writeToMapper(Mapper target, Object value, StringWriter writer) {
	if (value instanceof Collection) {
		target.writeArray((Collection<?>) value, writer);
	} else if (value.getClass().isArray()) {
		int len = Array.getLength(value);
		LinkedList<Object> list = new LinkedList<>();
		for (int i = 0; i < len; i++) {
			list.addLast(Array.get(value, i));
		}
		target.writeArray(list, writer);
	} else {
		target.writeObject(value, writer);
	}
}
 
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:15,代码来源:JsonJohnzon.java

示例10: setJumpOrderIterative

import java.util.LinkedList; //导入方法依赖的package包/类
public static void setJumpOrderIterative(PostingListNode<Integer> node) {
    LinkedList<PostingListNode<Integer>> queue = new LinkedList<>();
    PostingListNode<Integer> current = node;
    int order = 0;
    while (current != null || !queue.isEmpty()) {
        if (current == null || current.data != -1) {
            current = queue.poll();
        }
        if (current.data == -1)
            current.data = order++;
        if (current.next != null && current.next.data == -1)
            queue.addLast(current.next);
        current = current.jump;
    }
}
 
开发者ID:gardncl,项目名称:elements-of-programming-interviews-solutions,代码行数:16,代码来源:SearchPostingsList.java

示例11: getNotEndedGlobalAllEntitiesList

import java.util.LinkedList; //导入方法依赖的package包/类
public static LinkedList<Entity> getNotEndedGlobalAllEntitiesList(){
  LinkedList<Entity> returnList = new LinkedList<Entity>();
  for(Entity anEntity : globalAllEntitiesList){
    if(!anEntity.Trash) returnList.addLast(anEntity);
  }
  return returnList;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:8,代码来源:QnactrSimulation.java

示例12: getCards

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Gets a set amount of cards from the top of this card graveyard.
 * 
 * @param quantity
 *            The amount of cards to get from the top of this card
 *            graveyard.
 * 
 * @return All the cards determined by the quantity.
 */
public LinkedList<Card> getCards(int quantity) {
	LinkedList<Card> cardsToGet = new LinkedList<>();

	for (int i = 0; i < quantity; i++) {
		cardsToGet.addLast(cards.pop());
	}

	return cardsToGet;
}
 
开发者ID:Ativelox,项目名称:Rummy,代码行数:19,代码来源:CardGraveyard.java

示例13: sendRaw

import java.util.LinkedList; //导入方法依赖的package包/类
private void sendRaw(int index, Object message) {
    Reaction selectedReaction = null;
    Object[] args = null;
    synchronized (this) {
        final LinkedList<Object> writing = writes[index];
        if (writing == null) {
            throw new IndexOutOfBoundsException();
        }
        writing.addLast(message);
        mask |= 1L << index;
        final Reaction[] reactions = reactionsPerChannel[index];
        for (Reaction reaction : reactions) {
            if ((reaction.mask & mask) == reaction.mask) {
                final int[] indices = reaction.indices;
                args = new Object[indices.length];
                for (int i = 0; i < indices.length; ++i) {
                    final int readIndex = indices[i];
                    final LinkedList<Object> reading = writes[readIndex];
                    args[i] = reading.removeFirst();
                    if (reading.isEmpty()) {
                        mask &= ~(1L << readIndex);
                    }
                }
                selectedReaction = reaction;
                break;
            }
        }
    }
    if (selectedReaction != null) {
        selectedReaction.dispatch(this, args);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:33,代码来源:Join.java

示例14: preAutoWire

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
protected LinkedList<OutputPort> preAutoWire(LinkedList<OutputPort> readyOutputs) throws OperatorException {
	getLogger().info("Simulating IOSelectOperator with old stack: " + readyOutputs);
	Class<? extends IOObject> clazz = getSelectedClass();
	int number = getParameterAsInt(PARAMETER_SELECT_WHICH);
	int hits = 0;
	OutputPort myPort = null;
	Iterator<OutputPort> i = readyOutputs.descendingIterator();
	int count = 0;
	while (i.hasNext()) {
		OutputPort port = i.next();
		if (!port.shouldAutoConnect()) {
			continue;
		}
		if ((port.getMetaData() != null) && clazz.isAssignableFrom(port.getMetaData().getObjectClass())) {
			hits++;
			if (hits == number) {
				myPort = port;
				i.remove();
			} else if (getParameterAsBoolean(PARAMETER_DELETE_OTHERS)) {
				count++;
				i.remove();
			}
		}
	}
	if (myPort != null) {
		readyOutputs.addLast(myPort);
		getLogger().info("Bringing output port to front: " + myPort.getSpec());
	}
	if (count > 0) {
		getLogger().info("Deleted " + myPort.getSpec() + " output ports.");
	}
	getLogger().info("New stack is: " + readyOutputs);
	return readyOutputs;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:IOSelectOperator.java

示例15: deleteEntity

import java.util.LinkedList; //导入方法依赖的package包/类
private void deleteEntity(Object entity, LinkedList<Object> context) {
        if(entity == null) return;

        context.addLast(entity);

        Object id = ReflectionUtils.getAnnotatedFieldValue(entity, Id.class);
        if(id == null)
        id = ReflectionUtils.getAnnotatedMethodReturnValue(entity, Id.class);
        if(id == null)
        throw new EventPublishException("Can't get entity id from " + entity);

        Class<?> domainClass = entity.getClass();
        String index = DocumentUtils.getIndexName(domainClass);
        String type = DocumentUtils.getTypeName(domainClass);

        EventContainer.addEvent(new Event.DeleteEvent(Event.EventType.DELETE, id, index, type, null));

        Collection<Object> cascadeEntity = getCascadeEntity(entity, context);
        cascadeEntity.forEach((e) -> {
            if(e instanceof Iterable) {
                deleteIterable((Iterable)e, context);
            }else {
                deleteEntity(e, context);
            }
        });

        context.removeLast();
}
 
开发者ID:chaokunyang,项目名称:jkes,代码行数:29,代码来源:EventSupport.java


注:本文中的java.util.LinkedList.addLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。