diff CircularQueue.c @ 1:a8a8fe374984

Subversion era
author Eric Wing <ewing . public |-at-| gmail . com>
date Wed, 27 Oct 2010 16:51:16 -0700
parents 01e39f9f58d5
children 279d0427ef26
line wrap: on
line diff
--- a/CircularQueue.c	Wed Oct 27 16:50:19 2010 -0700
+++ b/CircularQueue.c	Wed Oct 27 16:51:16 2010 -0700
@@ -266,6 +266,22 @@
 	fprintf(stderr, "\n");
 }
 
+unsigned int CircularQueueUnsignedInt_ValueAtIndex(CircularQueueUnsignedInt* queue, unsigned int the_index)
+{
+	unsigned int i;
+	if(NULL == queue)
+	{
+		return 0;
+	}
+	if(the_index >= queue->currentSize)
+	{
+		return 0;
+	}
+	i = (queue->headIndex + the_index) % queue->currentSize;
+//	fprintf(stderr, "%d\n", queue->internalQueue[i]);
+	return queue->internalQueue[i];
+}
+
 /*
  * Implementation for void* version starts here.
  */
@@ -485,8 +501,6 @@
 	queue->tailIndex = 0;
 }
 
-/* Not implemented for void* */
-/*
 void CircularQueueVoid_Print(CircularQueueVoid* queue)
 {
 	unsigned int i;
@@ -502,11 +516,25 @@
 		{
 			i=0;
 		}
-		fprintf(stderr, "%d ", queue->internalQueue[i]);
+		fprintf(stderr, "%x ", (unsigned int)queue->internalQueue[i]);
 	}
 	fprintf(stderr, "\n");
 }
-*/
+
+void* CircularQueueVoid_ValueAtIndex(CircularQueueVoid* queue, unsigned int the_index)
+{
+	unsigned int i;
+	if(NULL == queue)
+	{
+		return NULL;
+	}
+	if(the_index >= queue->currentSize)
+	{
+		return NULL;
+	}
+	i = (queue->headIndex + the_index) % queue->currentSize;
+	//	fprintf(stderr, "%d\n", queue->internalQueue[i]);
+	return queue->internalQueue[i];
+}
 
 
-