| 1204 | * @param {DoublyLinkedCell<Data>} selfCell |
| 1205 | */ |
| 1206 | const spliceAfter= (prev, selfCell)=> { |
| 1207 | if( prev=== selfCell) { |
| 1208 | throw TypeError('Cannot splice a cell into itself'); |
| 1209 | } |
| 1210 | if( selfCell.next!== selfCell|| selfCell.prev!== selfCell) { |
| 1211 | throw TypeError('Expected self-linked cell'); |
| 1212 | } |
| 1213 | const cell= selfCell; |
| 1214 | // rename variable cause it isn't self-linked after this point. |
| 1215 | |
| 1216 | const next= prev.next; |
| 1217 | cell.prev= prev; |
| 1218 | cell.next= next; |
| 1219 | prev.next= cell; |
| 1220 | next.prev= cell; |
| 1221 | // Not frozen! |
| 1222 | return cell; |
| 1223 | }; |
| 1224 | |
| 1225 | /** |
| 1226 | * @template Data |