Author Topic: ResbufList class  (Read 11725 times)

0 Members and 1 Guest are viewing this topic.

gswang

  • Newt
  • Posts: 114
Re: ResbufList class
« Reply #15 on: October 31, 2010, 09:26:49 PM »
命令: (resbuf_remove 1 2 3 4 5)
(1 2 3 4 5)     ;Not what i want. :-(

Quote
   static int ads_resbuf_remove(void)
   {
      ResbufList _list = acedGetArgs();

      ResbufList args = _list;
      ResbufList_iterator iter = args.begin();

      int i = 0;
      for(; iter != args.end(); ++iter)
      {
         if (i == 1)
            _list.remove(const_cast<resbuf*>(&(*iter)));

         i++;
      }
      
      acedRetList(_list);

      return (RSRSLT);
   }
« Last Edit: October 31, 2010, 09:31:01 PM by gswang »

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: ResbufList class
« Reply #16 on: November 02, 2010, 10:27:39 PM »
Ah! I see the problem I will fix it tonight

gswang

  • Newt
  • Posts: 114
Re: ResbufList class
« Reply #17 on: November 02, 2010, 10:46:01 PM »
Thank you Daniel, recently busy, right? :-)
« Last Edit: November 03, 2010, 09:53:38 AM by gswang »

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: ResbufList class
« Reply #18 on: November 03, 2010, 09:12:17 PM »
Try it now  :-)

Code: [Select]
// (rbtest 1 2 3 4 5 6 7 8 9 0)
  static int ads_rbtest(void)
   {
      ResbufList args = acedGetArgs();

      //added this
      args.removeAt(1);

      ResbufList_iterator iter = args.begin();
      int i = 0;
      for(; iter != args.end(); ++iter)
      {
        if (i == 1)
             args.remove(iter);
         i++;
      }
      acedRetList (args);
      return (RSRSLT);
   }

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: ResbufList class
« Reply #19 on: November 03, 2010, 09:14:57 PM »
BTY, I changed a couple of function names  :whistle:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ResbufList class
« Reply #20 on: November 04, 2010, 12:17:07 AM »
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: ResbufList class
« Reply #21 on: November 04, 2010, 01:28:03 AM »
I know, I know.... but I did comment the code (a little)  :|

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: ResbufList class
« Reply #22 on: November 04, 2010, 01:37:58 AM »
I changed push_back(resbuf*)  to only accept a single node (for performance) and added  append_front(resbuf*) and append_back(resbuf*)  for chains.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ResbufList class
« Reply #23 on: November 04, 2010, 04:36:07 AM »
I know, I know.... but I did comment the code (a little)  :|

It's cool Daniel ... I'm just stirring  :-P
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

gswang

  • Newt
  • Posts: 114
Re: ResbufList class
« Reply #24 on: November 10, 2010, 06:32:18 AM »
 :?The push_back function could not work correctly!
ResbufList returnBuffer;
for(size_t idx =0; idx<points.length(); idx++)
{
resbuf *pTmp = acutNewRb(RT3DPOINT);
pTmp->resval.rpoint[0] = points[idx].x;
pTmp->resval.rpoint[1] = points[idx].y;
pTmp->resval.rpoint[2] = points[idx].z;
returnBuffer.push_back(pTmp);
}
« Last Edit: November 10, 2010, 06:48:33 AM by gswang »

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: ResbufList class
« Reply #25 on: November 10, 2010, 07:11:43 AM »
fixed, try it now

frtfff

  • Bull Frog
  • Posts: 215
Re: ResbufList class
« Reply #26 on: December 24, 2010, 10:15:21 PM »
 :-(

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: ResbufList class
« Reply #27 on: December 24, 2010, 10:24:56 PM »
why the long face?

pkohut

  • Bull Frog
  • Posts: 431
Re: ResbufList class
« Reply #28 on: March 24, 2011, 09:46:03 AM »
A year after the comments and I finally get to take at look at the changes you made. Looks good Daniel.
Code: [Select]
inline ResbufList_iterator ResbufList::begin()
{
  return (mpHead == NULL ? NULL : mpHead);
}
Compiler will probably optimize to:
   return mpHead;
but if not then it's a wasted if statement.


The loops structures in ResbufList::at and ResbufList::removeAt can become -
Code: [Select]
ResbufList_iterator ResbufList::at( const size_t idx )

  for(size_t nItems = 0, resbuf *pRbTemp = mpHead ; pRbTemp != NULL ; pRbTemp = pRbTemp->rbnext, ++nItems)
  {
    if(idx == nItems)
      return pRbTemp;
  }
  return NULL;
}

frtfff

  • Bull Frog
  • Posts: 215
Re: ResbufList class
« Reply #29 on: March 24, 2011, 11:32:52 PM »
Good code,but I don't know how to use.