C++ List (Real examples, Sorting a list, When (not) to use List, Detailed explanation, Step-by-Step)

preview_player
Показать описание
In this video, we are learning what are STL containers. I will teach you how to use lists in C++ with practical example. We will start with the basics of C++ lists and we will gradually move to more complex practical examples. You will learn how to create a matchmaking system that is used in many popular video games like PUBG, Warzone, Fortnite, and for that, we will use STL lists and iterators. I will also teach you the difference between lists and arrays (vectors). As part of this comparison, we will go through the main pros and cons of lists and vectors.
This video will help you understand the purpose of lists in C++, and in upcoming videos, we will cover the rest of the STL containers.

Additionally, if you want to gain more practical experience in building real apps and solving real problems, join my Practical Programming Course below.

Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

📚 Learn how to solve problems and build projects with these Free E-Books ⬇️

I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
It is a powerful, secure text editor designed specifically for programmers.

☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. ❤️😇

Related videos:

CONTENTS:
00:00 - What are STL Containers?
04:11 - How to use lists in C++?
05:03 - How to add elements to the list?
06:20 - How to print list elements?
10:00 - How to delete elements from the list?
11:22 - Using a list to build a game
12:35 - Creating a matchmaking system
19:42 - Passing elements by value VS passing elements by reference
21:18 - How to use const when passing elements by reference
24:01 - How to sort data in the list
29:01 - Pros and cons of the list
31:59 - Example of vectors in C++
34:00 - Lists vs vectors
34:18 - Conclusion

Add me on:
Рекомендации по теме
Комментарии
Автор

Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time!💰Use this coupon to save 10% (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

📚 Learn programming with these Free E-Books ⬇

FROM THE
#include <iostream>
#include<list>
using namespace std;

void displayRatings(const list<int>& playersRatings) {
for (list<int>::const_iterator it = playersRatings.begin(); it != playersRatings.end(); it++) {
cout << "Player rating: " << *it << endl;
}
}

void newPlayerRating, list<int>& playersByRating) {
for (list<int>::iterator it = playersByRating.begin(); it != playersByRating.end(); it++) {
if (*it > newPlayerRating) {
playersByRating.insert(it, newPlayerRating);
return;
}
}

}

int main()
{
list<int> allPlayers = {2, 9, 6, 7, 3, 1, 4, 8, 3, 2, 9};

list<int> beginners; //rating 1-5
list<int> pros;//rating 6-10

for (list<int>::iterator it = allPlayers.begin(); it != allPlayers.end(); it++) {
int rating = *it;
if (rating >= 1 && rating <= 5)
insertPlayerIntoOrderedList(rating, beginners);
else if (rating >= 6 && rating <= 10)
insertPlayerIntoOrderedList(rating, pros);
}

cout << "Beginners:" << endl;
displayRatings(beginners);
cout << "Pros:" << endl;
displayRatings(pros);

cin.get();
}

CodeBeauty
Автор

honestly, this channel is so good that it sums up all the lectures from university in around 30 mins, even more understandable than dry lessons from uni. Thank you

khiemnguyenhoang
Автор

You really helped me a lot, im a self taught because im still at high school.

I already learned pointers, oop, and some basic programming fundamentals from you, when will you make a tutorial for C++ sqlite?

Im not a native English speaker and i really love how you teached, you talk slow but very detailed... Plsss make a sqlite tutorial🙏

NYARNAV
Автор

Hey Saldina! Your videos have been a game-changer for me in learning programming. Can't wait to see what you have in store for us in your upcoming video!

ilyaskhan-jzbq
Автор

It sounds as an amazingly good guide in fundamental data structures and a list is a king of them.

kamertonaudiophileplayer
Автор

i was looking for this literally 2 days ago, i need it for my exams..you are master of the timing Saldina <3

hilgicamala
Автор

i thought yout channel is the best thing ever but your course is even better..im finishing my first year at university, you helped me alot <3

lulu_barcelonalulu_barcelona
Автор

Really excellent and helpful video😃
I can't understand y is this so underrated😢

poojaraman
Автор

this is great, i'm so glad that i found your channel and your practical programming course, greetings from Iceland

swbqrkc
Автор

Perfect timing I’m legit learning this in my computer science class

Daniel_florezzz
Автор

i watched your other video about lists and now i don't know which one is better, thank you Saldina :)

milkamilkica
Автор

From a beginner in C++ to solving 400+ DSA problems on leetcode yes that's all possible because of you 👍🏻👍🏻👍🏻, it wouldn't happen if I haven't learnt C++ from you 😅😅

neepunpatil
Автор

Oh boy😊! Waking up to another C++ coding video! Saldina keeps us on the edge of our seats and she never fails to amaze us✌️🤗!!

christopherrice
Автор

it's good that we have u in programming.
tnx(heart)

MohammadKarimi-qlnt
Автор

great video Saldina, i want to praise your Practical Course, i'm learning a lot and i'm very eager to find out what have you prepared for us next

codeoasis
Автор

thank you sooo much for that wonderful content

Hello_world
Автор

hey there..i really like your videos, so much that i enrolled your course immediately when you published it and it is great, i would highly encourage everyone to do the same

hazarder-njlw
Автор

Perfectly explained. Thank you very much for that 🙂

melvinsmile
Автор

great content saldina, i'm enrolled in your course too and im preparing for my finals, wish me luck :D

robirobi
Автор

8:30 I was wondering is there any reason you didn't show the way to iterate over objects in the list with std::for_each or as:
for(auto item : list)
{
}

Syntax?

I feel it would be helpful to try and teach, but I know it can also be difficult as it may introduce a new paradigm in programming, and requires knowledge that these require modern C++ features to be enabled like C++11 and the algorithm header.

ChrisCarlos