STL containers vs queues through linked lists

1) What is the difference between queues developed through linked list concept and STL containers?

2) In linked list concept we use pointers while in STL containers we use Iterators.So whats the difference b/w Iterators and object pointers.
1) std::list is a linked list, AFAIK. Hence, no difference, but one can assume that the STL version is not the worst implementation.

2) Iterator is a "smart pointer" that knows and makes use of what it does point to. Lets take your list:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct Node {
  Node * next;
};

// Have a pointer to list
Node * curr = ...
// Move to next
curr = curr->next;

// Have an iterator to list
Node_iterator iter = ...
// Move to next
++iter;

// Have pointer to array
int * val = ...
// Move to next
++val;

// Have iterator to array
Array::iterator * ait = ...
// Move to next
++ait;

Iterators are distinct types and can thus overload operators. Algorithms are decoupled from containers, as long as the containers provide compatible iterator objects.
What is the difference between queues developed through linked list concept and STL containers?

I do not understand the question. The C++ library offers std::list and std::queue so that you don't need to write them yourself.

If you're asking what's the difference in general between different kinds of containers, the answer is: how they were designed to function and store information.

For instance: std::vector stores elements contiguously in memory, so you can use vectors in cases where you traditionally use arrays.

std::list works by chaining elements. This increases speed for inserting and removing elements, especially when compared to vectors.

std::set internally uses some kind of binary tree data structure, and this makes finding an element very fast. Additionally, it cannot hold more than one element of the same value. If you want that you'd use std::multiset instead.

I would go on, but I have the feeling I'm wasting both my time and yours.
Topic archived. No new replies allowed.