Article View: att.lang.c++
Article #77help on dynamic q array
From: Joseph M Suprenant
Date: Sun, 02 Apr 2000 00:00
Date: Sun, 02 Apr 2000 00:00
44 lines
1424 bytes
1424 bytes
My question is this: I have a qlass and in it I am tring to implemet a
dynamic array Q
My trouble comes when i have to double the size of the dynamic array.
It
just does not get work corectly here is my code:
void Qclass::Double ()
{
int* temp;
int i=0;
int item;
temp=new int[Qlength*2-1];
int tempHead;
int tempTail;
tempHead=head;
tempTail=tail;
while(!IsEmpty())
{
DeQ(item);
temp[i]=item;
i++;
}
delete[] que;
que=temp;
head=tempHead;
tail=tempTail;
Qlength=Qlength*2-1;
}
..////Deq looks like this
void Qclass::DeQ (int& item)
{
head=(head+1)%Qlength;
item=que[head];
}
Could some kind soul give me some insight on this?
thanks
joe
Technical Details
Message-ID:
<38E70A6F.EB97579F@global2000.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,8abf11ac700271da,start X-Google-Attributes: gid10d4ba,public From: Joseph M Suprenant <laclac@global2000.net> Subject: help on dynamic q array Date: 2000/04/02 Message-ID: <38E70A6F.EB97579F@global2000.net> X-Deja-AN: 606390590 Content-Transfer-Encoding: 7bit X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: support@usenetserver.com Organization: WebUseNet Corp http://www.usenetserver.com - Home of the fastest NNTP servers on the Net. MIME-Version: 1.0 NNTP-Posting-Date: Mon, 03 Apr 2000 23:59:35 EDT Newsgroups: att.lang.c++