List indexOf - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:getString, isNull, put
	 */ 
	@Override 
	public boolean save(JSONObject newCalendarEvent) {
		try { 
			if (exists(newCalendarEvent)) {
				calendar1.set(	Integer.parseInt(newCalendarEvent.getString("id")),
							  	newCalendarEvent);
			} else { 
				calendar1.add(newCalendarEvent);
				newCalendarEvent.put("id", String.valueOf(calendar1.indexOf(newCalendarEvent)));
			} 
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false; 
		} catch (JSONException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false; 
		} 

7
CodeRank
This code example shows how to use the following methods:indexOf
    public T remove(final int index) {
        return delegate.remove(index);
    } 
 
    public int indexOf(final Object o) {
        return delegate.indexOf(o);
    } 
 
    public int lastIndexOf(final Object o) {
        return delegate.lastIndexOf(o);
    } 
 
    public ListIterator<T> listIterator() {
        return delegate.listIterator();
    } 
 
    public ListIterator<T> listIterator(final int index) {
        return delegate.listIterator(index);
    } 
 
7
CodeRank
This code example shows how to use the following methods:add, indexOf
     * java.util.ArrayList#indexOf(java.lang.Object) 
     */ 
    public void test_indexOfLjava_lang_Object() { 
        // Test for method int java.util.ArrayList.indexOf(java.lang.Object) 
        assertEquals("Returned incorrect index",
                87, alist.indexOf(objArray[87]));
        assertEquals("Returned index for invalid Object", -1, alist
                .indexOf(new Object()));
        alist.add(25, null);
        alist.add(50, null);
        assertTrue("Wrong indexOf for null.  Wanted 25 got: "
                + alist.indexOf(null), alist.indexOf(null) == 25);
    } 
 
    /** 
     * java.util.ArrayList#isEmpty() 
     */ 
    public void test_isEmpty() { 
        // Test for method boolean java.util.ArrayList.isEmpty() 
        assertTrue("isEmpty returned false for new list", new ArrayList()
7
CodeRank
This code example shows how to use the following methods:indexOf
  } 
 
  @Override 
  public int indexOf(T value)
  { 
    return baseList.indexOf(value);
  } 
 
  @Override 
  public Iterator<T> iterator()
  { 
    return baseList.iterator();
  } 
} 
7
CodeRank
This code example shows how to use the following methods:indexOf
    public long getItemId(int position) {
        return position;
    } 
 
    public int getPosition(T item) {
        return mObjects.indexOf(item);
    } 
 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        return createViewFromResource(position, convertView, parent, mResource);
    } 
 
    private void init(Context context, int resource, int textViewResourceId,
                      List<T> objects) {
        mContext = context;
        mInflater = LayoutInflater.from(context);
        mResource = mDropDownResource = resource;
        mObjects = objects;
        mFieldId = textViewResourceId;
7
CodeRank
This code example shows how to use the following methods:indexOf, size
         * @param qualifier 
         * @return an equivalent value that can be used with lexical comparison 
         */ 
        public static String comparableQualifier( String qualifier )
        { 
            int i = _QUALIFIERS.indexOf( qualifier );
 
            return i == -1 ? ( _QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i );
        } 
 
        public int compareTo( Item item )
        { 
            if ( item == null )
            { 
                // 1-rc < 1, 1-ga > 1 
                return comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX );
            } 
            switch ( item.getType() )
            { 
                case INTEGER_ITEM:
6
CodeRank
This code example shows how to use the following methods:addAll, indexOf
    public boolean addToDivider(T value, List<T> list) {
    	if (list == null || list.size() == 0) {
			return false; 
		} 
    	 
    	int i = dataList.indexOf(value);
    	if (i == -1) {
    		return false; 
    	} 
    	 
    	dataList.addAll(i, list);
    	this.notifyDataSetChanged();
    	 
    	return true; 
    } 
 
    public boolean addToLast(List<T> list) {
    	if (list == null || list.size() == 0) {
			return false; 
		} 
7
CodeRank
This code example shows how to use the following methods:get, indexOf, size
	 *  
	 * @param whichActivity 
	 *            the index of Activity 
	 */ 
	private void launchActivity(int whichActivity) {
		launchActivity(mActivities.get(whichActivity));
		maybeShowToast(whichActivity);
		maybeShowAnimation(whichActivity);
	} 
 
	/** 
	 * Add Activity NOTE: 添加的顺序很重要 
	 *  
	 * @param cls 
	 *            class of activity 
	 */ 
	public void addActivity(Class<?> cls) {
		mActivities.add(cls);
	} 
 

7
CodeRank
This code example shows how to use the following methods:indexOf, size
        private int val(String lang) {
            if(lang.equalsIgnoreCase(defaultLang)) {
                return 1000; 
            } 
 
            int index = prioritizedList.indexOf(lang);
            if(index > 0) {
                return prioritizedList.size() - index;
            } 
            return -1; 
        } 
    } 
6
CodeRank
This code example shows how to use the following methods:indexOf
		registry.registerBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME, beanDefinition);
		return beanDefinition;
	} 
 
	private static int findPriorityForClass(Class<?> clazz) {
		return APC_PRIORITY_LIST.indexOf(clazz);
	} 
 
	private static int findPriorityForClass(String className) {
		for (int i = 0; i < APC_PRIORITY_LIST.size(); i++) {
			Class<?> clazz = APC_PRIORITY_LIST.get(i);
			if (clazz.getName().equals(className)) {
				return i;
			} 
		} 
		throw new IllegalArgumentException(
				"Class name [" + className + "] is not a known auto-proxy creator class");
	} 
 
} 
6
CodeRank
indexOf Method Overview
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
See Code Examples for other Java 8 List Methods: