- wxNode *current = First();
- while (current)
- {
- if (!current->key.string)
- {
- wxFatalError (_("wxList: string key not present, probably did not Append correctly!"));
- break;
- }
- if (strcmp (current->key.string, key) == 0)
- return current;
- current = current->Next();
- }
+ // all objects in a keyed list should have a key
+ wxCHECK_MSG( m_keyType == wxKEY_NONE, (wxNodeBase *)NULL,
+ _T("need a key for the object to insert") );
+
+ wxCHECK_MSG( !position || position->m_list == this, (wxNodeBase *)NULL,
+ _T("can't insert before a node from another list") );
+
+ // previous and next node for the node being inserted
+ wxNodeBase *prev, *next;
+ if ( position )
+ {
+ prev = position->GetPrevious();
+ next = position;
+ }
+ else
+ {
+ // inserting in the beginning of the list
+ prev = (wxNodeBase *)NULL;
+ next = m_nodeFirst;
+ }
+
+ wxNodeBase *node = CreateNode(prev, next, object);
+ if ( !m_nodeFirst )
+ {
+ m_nodeLast = node;
+ }