PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Queue_Demo.cpp

Insert items from the user onto a Queue and then read them back at the terminal

cmake_minimum_required(VERSION 3.12)
find_package(PropWare REQUIRED)
project(Queue_Demo)
create_simple_executable(${PROJECT_NAME} Queue_Demo.cpp)
static const size_t ARRAY_SIZE_1 = 4;
int main () {
int array[ARRAY_SIZE_1];
Queue<int> buffer(array);
pwOut.printf("Please enter a number at each of the following six prompts:\n");
for (int i = 0; i < 6; ++i) {
int x;
pwOut << ">>> ";
pwIn >> x;
buffer.enqueue(x);
}
pwOut << "I received the following (" << ARRAY_SIZE_1 << ") values in this order:\n";
while (buffer.size())
pwOut << " " << buffer.dequeue() << "\n";
pwOut << "The Queue instance only had space for four objects, so you'll notice that\n"
<< "the first two numbers you entered are no longer in the Queue.\n";
return 0;
}
printer.h
PropWare::Printer::printf
void printf(const char fmt[], const T first, const Targs... remaining) const
Similar in functionality to the C-standard function printf.
Definition: printer.h:497
PropWare::Queue
A basic first-in, first-out queue implementation. The queue will overwrite itself when the maximum si...
Definition: queue.h:44
queue.h
main
int main(void)
Definition: GraphicsTest.c:20
PropWare.h
scanner.h
x
int x
Definition: 07 Box and Lines.c:13
pwOut
PropWare::Printer pwOut
Most common use of printing in PropWare applications (not thread safe; see PropWare::pwSyncOut for mu...
PropWare
Generic definitions and functions for the Parallax Propeller.
Definition: runnable.h:33