std::list

cppreference.com

Example

main: () = {
    // Create a list containing integers
    l: std::list = (7, 5, 16, 8);
 
    // Add an integer to the front of the list
    l.push_front(25);
    // Add an integer to the back of the list
    l.push_back(13);
 
    // Insert an integer before 16 by searching
    it:= std::find(l.begin(), l.end(), 16);
    if (it != l.end()) {
        l.insert(it, 42);
    }
 
    // Print out the list
    std::cout << "l = { ";
    for l do (n)
        std::cout << "(n)$, ";
    std::cout << "};\n";
}

Output

l = { 25, 7, 5, 42, 16, 8, 13, };

Back to top

cpp2reference.com licensed under CC-BY-SA and GFDL.