What is a two way templatized linked list in C++? Does it mean using syntax below for classes and member functions definitons?

template<typename type_variable>

>What is a two way templatized linked list in C++?
It's a standard container:

#include <iostream>
#include <list>

int main()
{
  std::list<int> my_list;

  for ( int i = 0; i < 10; i++ ) {
    if ( i % 2 == 0 )
      my_list.push_front ( i );
    else
      my_list.push_back ( i );
  }

  std::list<int>::iterator it = my_list.begin();

  while ( it != my_list.end() )
    std::cout<< *it++ <<'\n';
}

Not trying to be difficult but I am not as advanced as you with this C language and don't know if I ever will be. So, what does that mean? Can you explain the code you wrote to me as if you were talking to me face to face. I have to create a program using a 2-way templatized linked list class in C++ in a Josephus problem and I don't understand what that means.

I appreciate all your comments and help you have given me in the past but I just need to understand what to do here.

What narue has shown is a container (list) which holds an unlimited number of integers. She has shown that you can add to the front of the list of integers (via push_front) and can add to the end of the list of integers (via push_back) . She's putting all the even numbers in the front and the odd numbers at the end. She's then iterating through the list and printing them out.

So it means that you can insert values,strings, whatever at either end of the link list. Hence,the word two-way correct?
bye the way thanks to both of you for your replies.

The "two way" part of its name means that you can iterate in both directions.

That is, if you have an iterator pointing at a particular element of the list, you can move the iterator to the previous element or to the following element. Other styles of linked lists are singly-linked, meaning that given a certain node in the list, you can move forward, but not backwards.

This article has been dead for over six months. Start a new discussion instead.