test
Fork of nRF51822 by
Diff: btle/btle_discovery.h
- Revision:
- 299:19064275c0e0
- Parent:
- 295:5566c7b83bb5
- Child:
- 301:59e7404a4ea3
--- a/btle/btle_discovery.h Fri Jun 19 15:55:28 2015 +0100 +++ b/btle/btle_discovery.h Fri Jun 19 15:55:28 2015 +0100 @@ -128,17 +128,24 @@ serviceIndices[index] = INVALID_SERVICE_INDEX; } } - void append(int serviceIndex) { + void enqueue(int serviceIndex) { serviceIndices[numIndices++] = serviceIndex; } unsigned getFirst(void) const { return serviceIndices[0]; } - void removeFirst(void) { + int dequeue(void) { + if (numIndices == 0) { + return INVALID_SERVICE_INDEX; + } + + unsigned valueToReturn = serviceIndices[0]; numIndices--; - for (unsigned index = 0; index < numIndices; index++) { - serviceIndices[index] = serviceIndices[index + 1]; + for (unsigned i = 0; i < numIndices; i++) { + serviceIndices[i] = serviceIndices[i + 1]; } + + return valueToReturn; } size_t getCount(void) const { return numIndices;