New Posts  All Forums:Forum Nav:

C/C++ help?

post #1 of 5
Thread Starter 
Hello,

So I am writing this program for class and the wording kind of has me stumped...

" If the command is to enqueue then prompt the user to enter a line of text, read it in, enqeue it, and tell the user whether it was successful or not
If the command is to dequeue then attempt to dequeue a line of text, if successful then display it, otherwise display an error message "

The enqueue was easy, but for the dequeue are they asking me to ask the user to enter a string or am I just suppose to dequeue the string? If I don't ask the user for the value to dequeue then what do I put for the argument when I call the function??
Code:
bool enqueue(string s);
bool dequeue(string &s);

Any help is appreciated!

Edit: If there is no user input I realize I would just dequeue the front string but I don't need an argument to do that :?
Edited by canadianpanda - 3/3/13 at 1:45pm
Chidori
(13 items)
 
  
CPUMotherboardGraphicsRAM
intel i7 870 Asus P7P55D-E PRO Sapphire 7950 OC 8GB - G.Skill DDR3 1600 (Ripjaws) 
Hard DriveOptical DriveOSMonitor
C300 128GB SSD,2 x WD Cavier Black 1TB,500GB Green Asus DVD-RW Windows 8 64-bit 3 x Asus VE248H (24') 
KeyboardPowerCaseMouse
Das Mechnical Corsair Professional HX850W Lian Li Lancool PC-K62 Logitech G9x 
Mouse Pad
Qck+ steel 
  hide details  
Reply
Chidori
(13 items)
 
  
CPUMotherboardGraphicsRAM
intel i7 870 Asus P7P55D-E PRO Sapphire 7950 OC 8GB - G.Skill DDR3 1600 (Ripjaws) 
Hard DriveOptical DriveOSMonitor
C300 128GB SSD,2 x WD Cavier Black 1TB,500GB Green Asus DVD-RW Windows 8 64-bit 3 x Asus VE248H (24') 
KeyboardPowerCaseMouse
Das Mechnical Corsair Professional HX850W Lian Li Lancool PC-K62 Logitech G9x 
Mouse Pad
Qck+ steel 
  hide details  
Reply
post #2 of 5
What is it meaning by enqueue and dequeue? is this a data structures type thing?
Router
(12 items)
 
  
Reply
Router
(12 items)
 
  
Reply
post #3 of 5
Thread Starter 
Thanks for the reply. I just figured it out when I got off work. Turns out I was being a noob redface.gif

And to answer your question , it was for a circular buffer using an array. Enqueue to add a value to the buffer and dequeue to remove the buffer from the top/front.
Chidori
(13 items)
 
  
CPUMotherboardGraphicsRAM
intel i7 870 Asus P7P55D-E PRO Sapphire 7950 OC 8GB - G.Skill DDR3 1600 (Ripjaws) 
Hard DriveOptical DriveOSMonitor
C300 128GB SSD,2 x WD Cavier Black 1TB,500GB Green Asus DVD-RW Windows 8 64-bit 3 x Asus VE248H (24') 
KeyboardPowerCaseMouse
Das Mechnical Corsair Professional HX850W Lian Li Lancool PC-K62 Logitech G9x 
Mouse Pad
Qck+ steel 
  hide details  
Reply
Chidori
(13 items)
 
  
CPUMotherboardGraphicsRAM
intel i7 870 Asus P7P55D-E PRO Sapphire 7950 OC 8GB - G.Skill DDR3 1600 (Ripjaws) 
Hard DriveOptical DriveOSMonitor
C300 128GB SSD,2 x WD Cavier Black 1TB,500GB Green Asus DVD-RW Windows 8 64-bit 3 x Asus VE248H (24') 
KeyboardPowerCaseMouse
Das Mechnical Corsair Professional HX850W Lian Li Lancool PC-K62 Logitech G9x 
Mouse Pad
Qck+ steel 
  hide details  
Reply
post #4 of 5
Quote:
Originally Posted by stumped View Post

What is it meaning by enqueue and dequeue? is this a data structures type thing?

Most likely it would be a QUEUE implementation. A queue is a First in First out datastructure, think of lining up to order fast food at macdonalds. Assuming nobody jumps the queue, the first person to line up should be the first to get served.

Enqueue = person enters queue
Dequeue = person leaves queue.

This can be implemented in a variety of ways. Array + counter, Dynamic array, linked list, etc.

And just for posterities sake, a queue is basically the oppososite of a stack, which is a first in last out container.
Felix
(11 items)
 
ESXi 1
(9 items)
 
Dexter
(12 items)
 
CPUMotherboardGraphicsRAM
Intel Core i7 3770S 3.1 GHz Socket 1155 Box  Intel DQ77KB Intel HD4000 integrated gpu STRONTIUM 8GB Sodimm Single DDR3 1600Mhz 
Hard DriveCoolingOSKeyboard
Intel 520 Series SATA3 25nm 120G 2.5' Scythe Kozuti CPU low profile heatsink fan Microsoft Windows 8 Pro w/ Media Centre Corsair Vengeance K90. Performance, MMO, Mechan... 
PowerCaseMouse
Dell 19V 4.62A (Round) PA-10 Original AC Adapter Antec ISK110 VESA Mini-ITX Case, 90-watt adapte... Corsair Vengeance M90. Performance, MMO, Mechan... 
CPUMotherboardGraphicsRAM
Intel Core i7 3770 3.40 GHz 8M LGA1155 Processor Intel DQ77MK Intel HD4000 integrated gpu STRONTIUM 8GB 1600MHz DDR3 Dimm Single Module P... 
Hard DriveCoolingOSCase
SanDisk Blade 4GB Scythe Big Shuriken Rev. 2 ESXi vSphere 5.1 Coolermaster Elite 343 MATX Mini Tower Case Bla... 
Other
Dell X3959 dual port Intel GbE NIC 
CPUMotherboardGraphicsRAM
Intel Ivy Bridge Core i7 3770K Unlocked Quad Core ASUS SABERTOOTH-Z77 PCI-E3.0 x 16 Motherboard Intel HD4000 integrated gpu Corsair Vengeance 16GB (4x4GB) DDR3 1600MHz CL9... 
Hard DriveHard DriveCoolingCooling
Western Digital Scorpio Black 2.5 inch 320GB Western Digital Caviar Raid Edition4 1000GB (1TB) Corsair Cooling Hydro Series H100 Liquid CPU Corsair "Air Series" SP120 Quiet Edition Case Fan 
OSPowerCaseOther
Openfiler 2.99-2 Corsair AX850 850W  Corsair Obsidian 650D Black Mid Tower Case with... Dell Perc 6/i RAID Controller 
  hide details  
Reply
Felix
(11 items)
 
ESXi 1
(9 items)
 
Dexter
(12 items)
 
CPUMotherboardGraphicsRAM
Intel Core i7 3770S 3.1 GHz Socket 1155 Box  Intel DQ77KB Intel HD4000 integrated gpu STRONTIUM 8GB Sodimm Single DDR3 1600Mhz 
Hard DriveCoolingOSKeyboard
Intel 520 Series SATA3 25nm 120G 2.5' Scythe Kozuti CPU low profile heatsink fan Microsoft Windows 8 Pro w/ Media Centre Corsair Vengeance K90. Performance, MMO, Mechan... 
PowerCaseMouse
Dell 19V 4.62A (Round) PA-10 Original AC Adapter Antec ISK110 VESA Mini-ITX Case, 90-watt adapte... Corsair Vengeance M90. Performance, MMO, Mechan... 
CPUMotherboardGraphicsRAM
Intel Core i7 3770 3.40 GHz 8M LGA1155 Processor Intel DQ77MK Intel HD4000 integrated gpu STRONTIUM 8GB 1600MHz DDR3 Dimm Single Module P... 
Hard DriveCoolingOSCase
SanDisk Blade 4GB Scythe Big Shuriken Rev. 2 ESXi vSphere 5.1 Coolermaster Elite 343 MATX Mini Tower Case Bla... 
Other
Dell X3959 dual port Intel GbE NIC 
CPUMotherboardGraphicsRAM
Intel Ivy Bridge Core i7 3770K Unlocked Quad Core ASUS SABERTOOTH-Z77 PCI-E3.0 x 16 Motherboard Intel HD4000 integrated gpu Corsair Vengeance 16GB (4x4GB) DDR3 1600MHz CL9... 
Hard DriveHard DriveCoolingCooling
Western Digital Scorpio Black 2.5 inch 320GB Western Digital Caviar Raid Edition4 1000GB (1TB) Corsair Cooling Hydro Series H100 Liquid CPU Corsair "Air Series" SP120 Quiet Edition Case Fan 
OSPowerCaseOther
Openfiler 2.99-2 Corsair AX850 850W  Corsair Obsidian 650D Black Mid Tower Case with... Dell Perc 6/i RAID Controller 
  hide details  
Reply
post #5 of 5
Quote:
Originally Posted by mitchtaydev View Post

Most likely it would be a QUEUE implementation. A queue is a First in First out datastructure, think of lining up to order fast food at macdonalds. Assuming nobody jumps the queue, the first person to line up should be the first to get served.

Enqueue = person enters queue
Dequeue = person leaves queue.

This can be implemented in a variety of ways. Array + counter, Dynamic array, linked list, etc.

And just for posterities sake, a queue is basically the oppososite of a stack, which is a first in last out container.

Yes i know that. I just wanted the OP to clarify so i didn't assume incorrectly.
Router
(12 items)
 
  
Reply
Router
(12 items)
 
  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming