[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hpux-cxx-dev
Subject:    CXX-DEV: Inserting into a RWTPtrSortedVector<T> vs
From:       "Rodney Stromlund" <Rodney.Stromlund () wnco ! com>
Date:       2002-07-19 21:24:11
[Download RAW message or body]

Hello all,  I have a method that needs to insert into a vector.  It does
not really care whether it is a sorted vector or an ordered vector ...
but it needs to handle both.

E.g.:

RWTPtrSortedVector<some_object_type , std::less<some_object_type> >
srt;
RWTPtrOrderedVector<some_object_type> ord;

func_read_objs( srt );
func_read_objs( ord );


Normally I would guess that they have a common parent class and there
are virtuals for insert ... at least that is what I what I have seen in
other container libraries.  But I cannot find such a common method.

The tree for RWTPtrSortedVector is:
   RWTPtrSortedVector<T>->RW_PSrtSeq->RW_PSeq->RW_PCntnr->RW_PBase

And the tree for RWTPtrOrderedVector is:
   RWTPtrOrderedVector<T>->RW_PSeq->RW_PCntnr->RW_PBase

So, since RW_PSeq is the first common ancestor, I would write:

   void func_read_objs( RW_PSeq<what?> *vec )
   {
      some_object_type *obj;

      while ( obj = read_obj_from_somewhere() )
      {
         vec->insert( obj );
      }

   }

But insert is not virtual.  So how do I do this?  There maybe over 360
different objects using vectors calling this function.  I would like to
stay away from template functions if I can.


Question #2:  I saw, in this group, someone ask if there is a
predefined macro (such as __FILE__) for the current method name.  Please
can someone post the answer again?  Thx.


-- 
Rodney Stromlund    (extension: 6484)
Southwest Airlines Co.  Dept: Systems
"History has called America and our allies to action,
 and it is both our responsibility and our privilege to fight freedom's
fight." - G. W. Bush
 _________________________________________________________________
 To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
    with the message UNSUBSCRIBE cxx-dev
 _________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic