| 408 | } |
| 409 | |
| 410 | void remove(T val){ |
| 411 | if(num <= 0 || !front){ |
| 412 | return; |
| 413 | } |
| 414 | |
| 415 | acquireLock(&lock); |
| 416 | |
| 417 | ListNode<T>* current = front; |
| 418 | |
| 419 | while(current && current != back && current->obj != val) current = current->next; |
| 420 | |
| 421 | if(current){ |
| 422 | current->prev->next = current->next; |
| 423 | current->next->prev = current->prev; |
| 424 | if (front == current) front = current->next; |
| 425 | if (back == current) back = current->prev; |
| 426 | |
| 427 | num--; |
| 428 | |
| 429 | if(cache.get_length() >= maxCache){ |
| 430 | kfree(current); |
| 431 | } else { |
| 432 | cache.add_back(current); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | releaseLock(&lock); |
| 437 | } |
| 438 | |
| 439 | |
| 440 | void remove(ListIterator<T>& it){ |
no test coverage detected