//checks if dynamic array needs to be expanded and then finds where the new event //should be inserted into the array and calls shiftarray() to put it there void Day::scheduleEvent(int startTime, int endTime, string description){ if (eventCount >= eventCapacity){ expandArray(); } if(eventCount == 0){ //checks if array is empty shiftArray(0, startTime, endTime, description); } if(startTime < eventList[0].getStartTime()){ //checks if event goes before 1st shiftArray(0, startTime, endTime, description); //event in the array } for(int i = 1; i < eventCount; i++){ //checks if event goes in the middle of array if((startTime > eventList[i - 1].getStartTime()) && (startTime < eventList[i].getStartTime())){ shiftArray(i, startTime, endTime, description); break; } if(startTime == eventList[i].getStartTime()){ //checks to see if event is the same shiftArray(i + 1, startTime, endTime, description); //as another event break; } } if(startTime > eventList[eventCount - 1].getStartTime()){ //checks if event goes at end of array shiftArray(eventCount, startTime, endTime, description); } }
bool Sequence::insert(int pos, const ItemType &value){ if (pos<0 || pos>length || pos>=capacity || length==capacity) { return false; } if (pos!=length) { shiftArray(FORWARD, pos); } array[pos] = value; length++; return true; }
void Motore::letturaEncoder() { bool n = digitalRead(pENC1); if ((pENC1Last == LOW) && (n == HIGH)) { int oldPos = x[0]; shiftArray(x); shiftArray(t); shiftArray(v); shiftArray(a); if (digitalRead(pENC2) == LOW) { x[0] = oldPos - 1; } else { x[0] = oldPos + 1; } t[0] = millis(); v[0] = (x[1]-x[0])/(t[1]-t[0]); a[0] = (v[1]-v[0])/(t[1]-t[0]); } pENC1Last = n; }
bool Sequence::insert(const ItemType &value){ if (length==capacity) { return false; } int i = 0; for (; i<length; i++) { if (array[i]>=value) { shiftArray(FORWARD, i); break; } } array[i] = value; length++; return true; }
bool Sequence::erase(int pos){ checkPos(pos) shiftArray(BACKWARD, pos); length--; return true; }
static void menu_pos_changed(struct MenuLayer *menu_layer, MenuIndex new_index, MenuIndex old_index, void *callback_context) { shiftArray(new_index.row); requestAdditionalEntries(); }