-
- if ( ( group < (*i)->GetGroup() )
- ||( group == (*i)->GetGroup() && element < (*i)->GetElement()) )
- {
- // instead of ReplaceOrCreateByNumber
- // that is a method of Document :-(
- ValEntry* entry = 0;
- TagKey key = DictEntry::TranslateToKey(group, element);
-
- // we assume a Public Dictionnary *is* loaded
- Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
- // if the invoked (group,elem) doesn't exist inside the Dictionary
- // we create a VirtualDictEntry
- DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, element);
- if (dictEntry == NULL)
- {
- dictEntry =
- Global::GetDicts()->NewVirtualDictEntry(group, element,
- "UN", GDCM_UNKNOWN, GDCM_UNKNOWN);
- }
- // we assume the constructor didn't fail
- entry = new ValEntry(dictEntry);
- if (entry)
- {
- entry->SetValue(val);
- }
- DocEntries.insert(i,entry);
-
- return true;
- }
- if (group == (*i)->GetGroup() && element == (*i)->GetElement() )
- {
- if ( ValEntry* entry = dynamic_cast<ValEntry*>(*i) )
- {
- entry->SetValue(val);
- }
- return true;
- }
- }
- return false;
-}
+ if ( (*it)->GetGroup() < entry->GetGroup() )
+ break;
+ else
+ if ( (*it)->GetGroup() == entry->GetGroup() &&
+ (*it)->GetElement() < entry->GetElement() )
+ break;
+ } while (it != DocEntries.begin() );
+
+ insertSpot = it++;
+ insertSpot++; // ?!?
+ DocEntries.insert(insertSpot, entry);
+ return true;
+}