Find the sub-list from the list and the sub-list from the list

Source: Internet
Author: User

Find the sub-list from the list and the sub-list from the list

The usage of the member function is very strange. An element is used to search in the list. If it is found, the elements found and all elements are converted into a new list and returned. If it cannot be found, nil is returned.

(set 'aList '(a b c d e f g h))  → (a b c d e f g h)(member 'd aList)                → (d e f g h)(member 55 aList)                → nil



How to find the location of a specified element from the LIST in java

List <Object> list = new ArrayList <Object> ();
......
Object oldObj =...
Object newObj =...
Int index = list. indexOf (oldObj );
If (index! =-1 ){
List. add (index, newObj );
List. remove (index + 1 );
}
......

If there is a problem with the above operations, your class may need to implement the Comparable Interface

What is the search function in STL list? How can I use it?

Use the General STL algorithm find () to search for objects in the list.
List <char >:: iterator FindIterator;
FindIterator = find (cList. begin (), cList. end (), 'C ');
If (FindIterator = cList. end ())
{
Printf ("not find the char 'C '! ");
}
Else
{
Printf ("% c", * FindIterator );
}
Note: If the specified object is not found, the value of cList. end () is returned. If it is found, a pointer to the iterator object is returned.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.