LinkedList get - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for LinkedList get method.

This code example shows how to use the following methods:isEmpty, get, size
	 
	public IType getDeclaratorType() { 
		// the declSpec may be null, so use getDeclSpec() 
		IType baseType = getDeclSpec().getType();
		 
		if(typeModifiers.isEmpty())
			return baseType;
		 
		IType type = typeModifiers.get(0);
		 
		// link the types together 
		for(int i = 1; i < typeModifiers.size(); i++) {
			ITypeContainer t1 = typeModifiers.get(i-1);
			ITypeContainer t2 = typeModifiers.get(i);
			t1.setType(t2);
		} 
		 
		ITypeContainer last = typeModifiers.get(typeModifiers.size()-1);
		last.setType(baseType);
		return type;

7
CodeRank
This code example shows how to use the following methods:get, size
        cb.addAllLast(i5);
        cb.addAllLast((List<HttpRequestInterceptor>) null);
        cb.addFirst(i1);
        cb.addAllLast(i3, i4, i5);
        final LinkedList<HttpRequestInterceptor> list = cb.build();
        Assert.assertNotNull(list);
        Assert.assertEquals(5, list.size());
        Assert.assertSame(i1, list.get(0));
        Assert.assertSame(i2, list.get(1));
        Assert.assertSame(i3, list.get(2));
        Assert.assertSame(i4, list.get(3));
        Assert.assertSame(i5, list.get(4));
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:listIterator, get
import java.util.ListIterator; 
 
public class Remove { 
    public static 
    void main(String[] args) {
        LinkedList list = new LinkedList();
        ListIterator e = list.listIterator();
        Object o = new Integer(1);
        e.add(o);
        e.previous();
        e.next();
        e.remove();
        e.add(o);
        if (!o.equals(list.get(0)))
            throw new RuntimeException("LinkedList ListIterator remove failed.");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:get, size
this.elements = new LinkedList<Object>(elements);
    } 
 
    public Object answer(InvocationOnMock invocation) throws Throwable {
        if (elements.size() == 1)
            return elements.get(0);
        else  
            return elements.poll();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:get, size
 
public class TestBundleAnalyzer extends TestCase {
	 
	public void testContentAndIdentity() throws Exception { 
		BundleAnalyzer a = new BundleAnalyzer(new NullLogSvc());
		LinkedList<Capability> caps = new LinkedList<Capability>();
		LinkedList<Requirement> reqs = new LinkedList<Requirement>();
		 
		a.analyzeResource(new JarResource(new File("testdata/01-bsn+version.jar")), caps, reqs);
		 
		assertEquals(4, caps.size());
		 
		Capability idcap = caps.get(0);
		assertEquals("osgi.identity", idcap.getNamespace());
		assertEquals("org.example.a", idcap.getAttributes().get("osgi.identity"));
		assertEquals("osgi.bundle", idcap.getAttributes().get("type"));
		assertEquals(new Version("0.0.0"), idcap.getAttributes().get("version"));
		 
		Capability content = caps.get(1);
		assertEquals("osgi.content", content.getNamespace());

6
CodeRank
This code example shows how to use the following methods:get, size
  public boolean isEmpty() { 
    return names.size() == 0;
  } 
 
  public String last() {
    return (names.size() == 0 ? null : names.get(names.size() - 1));
  } 
 
  public List<String> getNames() {
    return names;
  } 
 
  public String toString() {
    String prefix = "";
    if (mode == ABSOLUTE)
      prefix = ".";
    else if (mode == SUB_PAGE)
      prefix = ">";
    else if (mode == BACKWARD_SEARCH)
      prefix = "<";
6
CodeRank
This code example shows how to use the following methods:add, get
		cm.publish(taintedElement);
	} 
 
	public void linkedListConcreteWriteReadTest() { 
		String tainted = TelephonyManager.getDeviceId();
		LinkedList<String> list = new LinkedList<String>();
		list.add(tainted);
		// because whole list is tainted, even untainted elements are tainted if they are fetched from the list 
		String taintedElement2 = list.get(0);
 
		ConnectionManager cm = new ConnectionManager();
		cm.publish(taintedElement2);
	} 
 
	public void linkedListConcreteWriteReadNegativeTest() { 
		String tainted = TelephonyManager.getDeviceId();
		LinkedList<String> notRelevantList = new LinkedList<String>();
		LinkedList<String> list = new LinkedList<String>();
		list.add("neutral");
		notRelevantList.add(tainted);
6
CodeRank
This code example shows how to use the following methods:get, size
     
    private int fetchIndex(String val){
        int index = 0; 
        if(val.indexOf(']') == 1){
            //[]格式的路径, 即索引放在arrayIndex里面的. 
            if(arrayIndex.size() > arrayItem){
                index = arrayIndex.get(arrayItem ++);
            } 
        } else { 
            //[1]格式, 路径上自带索引 
            index = Integer.parseInt(val.substring(1, val.length() - 1));
        } 
        return index;
    } 
     
    /** 
     * 注入MAP 
     * @param obj 
     * @param i 
     */ 
6
CodeRank
This code example shows how to use the following methods:add, get, indexOf, remove
	/** 
	 * @tests java.util.LinkedList#remove(int) 
	 */ 
	public void test_removeI() { 
		// Test for method java.lang.Object java.util.LinkedList.remove(int) 
		ll.remove(10);
		assertEquals("Failed to remove element", -1, ll.indexOf(objArray[10]));
		try { 
			ll.remove(999);
            fail("Failed to throw expected exception when index out of range");
		} catch (IndexOutOfBoundsException e) {
			// Correct 
		} 
		 
		ll.add(20, null);
		ll.remove(20);
		assertNotNull("Should have removed null", ll.get(20));
	} 
 
	/** 

6
CodeRank
This code example shows how to use the following methods:get, size
 
    /** 
     * Returns the number of warnings. 
     */ 
    public int getWarningCount() { 
        return ((this.warnings == null) ? 0 : this.warnings.size());
    } 
 
    /** 
     * Returns the number of errors. 
     */ 
    public int getErrorCount() { 
        return ((this.errors == null) ? 0 : this.errors.size());
    } 
 
    /** 
     * Returns the specified warning message, or null. 
     */ 
    public WarningMessage getWarning(int index) {
        if (index < getWarningCount()) {

6
CodeRank
get Method Overview
Returns the element at the specified position in this list.
See Code Examples for other Java 8 LinkedList Methods: