public unsafe void Remove(bool value) { //TODO: make it work... BoolNode *Previous = head, actual = head->Next; while (actual != head) { if (actual->Value == value) { if (Previous == head->Previous) { head->Previous = actual->Next; } else { Previous->Next = actual->Next; } Marshal.FreeHGlobal((IntPtr)actual); actual = Previous == head->Previous ? head : Previous->Next; } else { Previous = actual; actual = actual->Next; } } }
public void Add(bool value) { unsafe { var node = (BoolNode *)(Marshal.AllocHGlobal(sizeof(BoolNode))); node->Value = value; node->Next = null; node->Previous = null; if (head == null) { head = node; head->Next = head; head->Previous = head; } else { var current = head; while (current != head) { current = current->Next; } current->Next = node; node->Previous = current; node->Next = head; nodeCount += 1; } } }