MCPcopy Create free account
hub / github.com/YatSenOS/YatSenOS-Tutorial-Volume-1 / insert

Method insert

lab8/src/6/src/utils/list.cpp:97–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void List::insert(int pos, ListItem *itemPtr)
98{
99 if (pos == 0)
100 {
101 push_front(itemPtr);
102 }
103 else
104 {
105 int length = size();
106 if (pos == length)
107 {
108 push_back(itemPtr);
109 }
110 else if (pos < length)
111 {
112 ListItem *temp = at(pos);
113
114 itemPtr->previous = temp->previous;
115 itemPtr->next = temp;
116 temp->previous->next = itemPtr;
117 temp->previous = itemPtr;
118 }
119 }
120}
121
122void List::erase(int pos)
123{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected