Robert Murrell / Sketchlet
Committer:
aerialspecs
Date:
Fri Jan 20 14:58:52 2017 +0000
Revision:
0:42e6dbd4dbeb
Initial import

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aerialspecs 0:42e6dbd4dbeb 1 /*
aerialspecs 0:42e6dbd4dbeb 2 * Copyright (c) 2017, Aerialspecs, Inc.
aerialspecs 0:42e6dbd4dbeb 3 *
aerialspecs 0:42e6dbd4dbeb 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
aerialspecs 0:42e6dbd4dbeb 5 * of this software and associated documentation files (the "Software"), to deal
aerialspecs 0:42e6dbd4dbeb 6 * in the Software without restriction, including without limitation the rights
aerialspecs 0:42e6dbd4dbeb 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
aerialspecs 0:42e6dbd4dbeb 8 * copies of the Software, and to permit persons to whom the Software is
aerialspecs 0:42e6dbd4dbeb 9 * furnished to do so, subject to the following conditions:
aerialspecs 0:42e6dbd4dbeb 10 *
aerialspecs 0:42e6dbd4dbeb 11 * The above copyright notice and this permission notice shall be included in all
aerialspecs 0:42e6dbd4dbeb 12 * copies or substantial portions of the Software.
aerialspecs 0:42e6dbd4dbeb 13 *
aerialspecs 0:42e6dbd4dbeb 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
aerialspecs 0:42e6dbd4dbeb 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
aerialspecs 0:42e6dbd4dbeb 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
aerialspecs 0:42e6dbd4dbeb 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
aerialspecs 0:42e6dbd4dbeb 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
aerialspecs 0:42e6dbd4dbeb 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
aerialspecs 0:42e6dbd4dbeb 20 * SOFTWARE.
aerialspecs 0:42e6dbd4dbeb 21 */
aerialspecs 0:42e6dbd4dbeb 22
aerialspecs 0:42e6dbd4dbeb 23 #include "Iterator.h"
aerialspecs 0:42e6dbd4dbeb 24
aerialspecs 0:42e6dbd4dbeb 25 namespace com {
aerialspecs 0:42e6dbd4dbeb 26 namespace aerialspecs {
aerialspecs 0:42e6dbd4dbeb 27 namespace mbed {
aerialspecs 0:42e6dbd4dbeb 28 namespace sketchlet {
aerialspecs 0:42e6dbd4dbeb 29
aerialspecs 0:42e6dbd4dbeb 30 template <class I> Iterator<I>::Iterator(I* elements, uint8_t length) {
aerialspecs 0:42e6dbd4dbeb 31 this->elements = elements;
aerialspecs 0:42e6dbd4dbeb 32 this->length = length;
aerialspecs 0:42e6dbd4dbeb 33 this->index = 0;
aerialspecs 0:42e6dbd4dbeb 34 }
aerialspecs 0:42e6dbd4dbeb 35
aerialspecs 0:42e6dbd4dbeb 36 template <class I> bool Iterator<I>::hasNext() {
aerialspecs 0:42e6dbd4dbeb 37 return (this->index < this->length);
aerialspecs 0:42e6dbd4dbeb 38 }
aerialspecs 0:42e6dbd4dbeb 39
aerialspecs 0:42e6dbd4dbeb 40 template <class I> I Iterator<I>::next() {
aerialspecs 0:42e6dbd4dbeb 41 I value;
aerialspecs 0:42e6dbd4dbeb 42
aerialspecs 0:42e6dbd4dbeb 43 if(this->hasNext()) {
aerialspecs 0:42e6dbd4dbeb 44 ++this->index;
aerialspecs 0:42e6dbd4dbeb 45 value = this->elements[this->index];
aerialspecs 0:42e6dbd4dbeb 46 }
aerialspecs 0:42e6dbd4dbeb 47
aerialspecs 0:42e6dbd4dbeb 48 return value;
aerialspecs 0:42e6dbd4dbeb 49 }
aerialspecs 0:42e6dbd4dbeb 50
aerialspecs 0:42e6dbd4dbeb 51 template <class I> void Iterator<I>::reset() {
aerialspecs 0:42e6dbd4dbeb 52 this->index = 0;
aerialspecs 0:42e6dbd4dbeb 53 }
aerialspecs 0:42e6dbd4dbeb 54
aerialspecs 0:42e6dbd4dbeb 55 template <class I> Iterator<I>::~Iterator() {
aerialspecs 0:42e6dbd4dbeb 56 //
aerialspecs 0:42e6dbd4dbeb 57 }
aerialspecs 0:42e6dbd4dbeb 58
aerialspecs 0:42e6dbd4dbeb 59 }}}}