MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / remove_at

Method remove_at

Kernel/include/list.h:145–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143 }
144
145 T remove_at(unsigned pos) {
146 assert(num > 0);
147 assert(pos < num);
148 assert(front != nullptr);
149
150 T current = front;
151
152 for (unsigned int i = 0; i < pos && current; i++) current = current->next;
153
154 assert(current);
155
156 if (current->next) current->next->prev = current->prev;
157 if (current->prev) current->prev->next = current->next;
158 if (front == current) front = current->next;
159 if (back == current) back = current->prev;
160
161 if(!(--num)) front = back = nullptr;
162
163 return current;
164 }
165
166 void remove(T obj){
167 if (obj->next) obj->next->prev = obj->prev;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected