/* If Map is NULL, then ASSERT(). If the Used doubly linked list is empty, then ASSERT(). */
VOID* EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
/* If Map is NULL, then ASSERT(). If the Used doubly linked list is empty, then ASSERT(). */
VOID* EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
{
  NET_MAP_ITEM  *Item;
  ASSERT (Map && !IsListEmpty (&Map->Used));
  Item = NET_LIST_HEAD (&Map->Used, NET_MAP_ITEM, Link);
  RemoveEntryList (&Item->Link);
  Map->Count--;
  InsertHeadList (&Map->Recycled, &Item->Link);
  if (Value != NULL) {
    *Value = Item->Value;
  }
  return Item->Key;
}