Lists and back() Question.

From: Larry Lindstrom (larryl_at_nospam.com)
Date: 12/16/03


Date: Tue, 16 Dec 2003 10:54:55 -0800

Hi Experts:

    I'm not familiar with STL. I'm trying to use
a list as follows:

class TEST_RECORD
{
      int a;
      char b;
};

typedef list<TEST_RECORD *> TEST_LIST;

void test_function()
{
      TEST_LIST test_list;
      TEST_LIST::const_iterator test_iterator;
      TEST_RECORD *test_record_ptr;

      test_record_ptr = new TEST_RECORD;
      test_list.push_back(test_record_ptr);
      test_iterator = test_list.back(); <-- error
      test_iterator = test_list.begin();
}

    I want to start examining the back of the list
and move toward the front. Setting the iterator
at test_list.back yields the following from MSVC6:

      error C2679: binary '=' : no operator defined
      which takes a right-hand operand of type
      'class TEST_RECORD *' (or there is no acceptable
      conversion)

    Assigning the to test_list.begin raises no
complaints.

    I know the details of STL containers are
opaque, but they to behave as double linked
lists. Isn't there a method to move to the
tail of a list without traversing it from
the front?

                                      Thanks
                                      Larry



Relevant Pages

  • Re: mutable list iterators - a proposal
    ... > Replacing items, which is by far the most common need, works fine. ... >> through which the iterator has already passed, ... The fact that lists don't ... def SetBottom: ...
    (comp.lang.python)
  • Re: Fast expanding macros /Was: How to declare recursive factorial function?
    ... that works purely by expansion, in which cases is it possible to make it ... and a purely expandable macro comparing two items ... Let the iterator modify these arguments during iteration... ... lists you always need to decide upon the treatment of "edge- ...
    (comp.text.tex)
  • Re: Iterator Class?
    ... >> there is a significant performace penalty when using getfor long Lists. ... >> available albeit at a slight performance penalty compared to Iterator. ... Farsight Systems Corporation ...
    (comp.lang.java.programmer)
  • Re: Iterator Class?
    ... >> there is a significant performace penalty when using getfor long Lists. ... >> available albeit at a slight performance penalty compared to Iterator. ... Farsight Systems Corporation ...
    (comp.lang.java.help)
  • Event listener list implementation
    ... I am looking for java.util.List implementation for event listeners ... of synchronization using copy-on-write mode. ... dominant ops are reads (such as event listener lists) then it is ... Related to, when firing events using an iterator, iterator ...
    (comp.lang.java.programmer)