Click here to Skip to main content
15,885,032 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow can merge 2 CUIntArray? Pin
Le@rner8-Apr-10 23:59
Le@rner8-Apr-10 23:59 
AnswerRe: How can merge 2 CUIntArray? Pin
Eugen Podsypalnikov9-Apr-10 0:17
Eugen Podsypalnikov9-Apr-10 0:17 
GeneralRe: How can merge 2 CUIntArray? Pin
Le@rner9-Apr-10 0:27
Le@rner9-Apr-10 0:27 
GeneralRe: How can merge 2 CUIntArray? [modified] Pin
CPallini9-Apr-10 0:42
mveCPallini9-Apr-10 0:42 
GeneralRe: How can merge 2 CUIntArray? [modified] Pin
Eugen Podsypalnikov9-Apr-10 0:57
Eugen Podsypalnikov9-Apr-10 0:57 
GeneralRe: How can merge 2 CUIntArray? Pin
CPallini9-Apr-10 1:08
mveCPallini9-Apr-10 1:08 
GeneralRe: How can merge 2 CUIntArray? Pin
Eugen Podsypalnikov9-Apr-10 1:13
Eugen Podsypalnikov9-Apr-10 1:13 
GeneralRe: How can merge 2 CUIntArray? [updated] Pin
CPallini9-Apr-10 2:36
mveCPallini9-Apr-10 2:36 
The following function works (at least I suppose it does...) with increasing-ordered arrays (without duplicate items):
// merges arrays 'l' and 'r' into 'o'.
// precondition: 'l','r' should be increasing-ordered, (without duplicate items).
void MergeArrays(CUIntArray & l, CUIntArray & r, CUIntArray & o)
{
  int il = 0, ir = 0;
  int lcount, rcount;
  lcount = l.GetCount();
  rcount = r.GetCount();
  o.RemoveAll();
  for (;;)
  {
    if ( il == lcount)
    {
      if ( ir == rcount) return;
      o.Add(r[ir]);
      ir++;
    }
    else
    {
      if ( ir == rcount)
      {
        o.Add(l[il]);
        il++;
      }
      else
      {
        if (l[il] < r[ir])
        {
          o.Add(l[il]);
          il++;
        }
        else if (l[il] > r[ir])
        {
          o.Add(r[ir]);
          ir++;
        }
        else
        {
          o.Add(l[il]);
          il++; ir++;
        }
      }
    }
  }
}

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]
modified on Friday, April 9, 2010 9:14 AM

GeneralRe: How can merge 2 CUIntArray? Pin
Eugen Podsypalnikov9-Apr-10 3:05
Eugen Podsypalnikov9-Apr-10 3:05 
GeneralRe: How can merge 2 CUIntArray? Pin
CPallini9-Apr-10 3:17
mveCPallini9-Apr-10 3:17 
GeneralRe: How can merge 2 CUIntArray? Pin
Eugen Podsypalnikov9-Apr-10 3:34
Eugen Podsypalnikov9-Apr-10 3:34 
GeneralRe: How can merge 2 CUIntArray? Pin
CPallini9-Apr-10 7:11
mveCPallini9-Apr-10 7:11 
AnswerRe: How can merge 2 CUIntArray? Pin
CPallini9-Apr-10 0:23
mveCPallini9-Apr-10 0:23 
GeneralRe: How can merge 2 CUIntArray? Pin
David Crow9-Apr-10 3:54
David Crow9-Apr-10 3:54 
GeneralRe: How can merge 2 CUIntArray? Pin
CPallini9-Apr-10 7:16
mveCPallini9-Apr-10 7:16 
GeneralRe: How can merge 2 CUIntArray? Pin
David Crow9-Apr-10 7:40
David Crow9-Apr-10 7:40 
GeneralRe: How can merge 2 CUIntArray? Pin
CPallini9-Apr-10 8:35
mveCPallini9-Apr-10 8:35 
GeneralRe: How can merge 2 CUIntArray? Pin
Eugen Podsypalnikov9-Apr-10 9:42
Eugen Podsypalnikov9-Apr-10 9:42 
QuestionMarquee Progress Control Pin
JM22518-Apr-10 21:32
JM22518-Apr-10 21:32 
AnswerRe: Marquee Progress Control Pin
Eugen Podsypalnikov8-Apr-10 22:07
Eugen Podsypalnikov8-Apr-10 22:07 
GeneralRe: Marquee Progress Control Pin
JM22518-Apr-10 22:16
JM22518-Apr-10 22:16 
GeneralRe: Marquee Progress Control Pin
Eugen Podsypalnikov8-Apr-10 22:55
Eugen Podsypalnikov8-Apr-10 22:55 
GeneralRe: Marquee Progress Control [modified] Pin
JM22518-Apr-10 23:32
JM22518-Apr-10 23:32 
GeneralRe: Marquee Progress Control Pin
Eugen Podsypalnikov8-Apr-10 23:47
Eugen Podsypalnikov8-Apr-10 23:47 
GeneralRe: Marquee Progress Control Pin
JM22518-Apr-10 23:51
JM22518-Apr-10 23:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.