🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: att.lang.c++
Article #80

Re: help on dynamic q array

#80
From: js
Date: Wed, 05 Apr 2000 00:00
52 lines
1671 bytes
Unless you need to do this for a class assignment, I'd use a stl vector.

Joseph M Suprenant <laclac@global2000.net> wrote in message
news:38E70A6F.EB97579F@global2000.net...
> 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: <wOLG4.864$P12.96449@nntp0.chicago.il.ameritech.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38E70A6F.EB97579F@global2000.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d4ba,8abf11ac700271da
X-Google-Attributes: gid10d4ba,public
From: "js" <jeeves_97@yahoo.com>
Subject: Re: help on dynamic q array
Date: 2000/04/05
Message-ID: <wOLG4.864$P12.96449@nntp0.chicago.il.ameritech.net>
X-Deja-AN: 607185797
References: <38E70A6F.EB97579F@global2000.net>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Trace: nntp0.chicago.il.ameritech.net 954960156 199.179.162.32 (Wed, 05 Apr 2000 13:42:36 CDT)
Organization: Ameritech.Net www.ameritech.net  Complaints: abuse@ameritech.net
X-MSMail-Priority: Normal
NNTP-Posting-Date: Wed, 05 Apr 2000 13:42:36 CDT
Newsgroups: att.lang.c++