code: public ElementId addDefined(char[] buffer, int start, int len, int hash,
                                  Location loc, PrefixedName elemName, PrefixedName attrName)
      {
          int index = (hash & mIndexMask);
          ElementId id = mTable[index];
  
          while (id != null) {
              if (id.idMatches(buffer, start, len)) {
                  break;
              }
              id = id.nextColliding();
          }
  
          /* Not found, can just add it to the Map; no need to add to the
           * linked list as it's not undefined
           */
          if (id == null) {
              // First, do we need more room?
              if (mSize >= mSizeThreshold) {
                  rehash();
                  index = (hash & mIndexMask);
              }
              ++mSize;
              String idStr = new String(buffer, start, len);
              id = new ElementId(idStr, loc, true, elemName, attrName);
              id.setNextColliding(mTable[index]);
              mTable[index] = id;
          } else {
              /* If already defined, nothing additional to do (we could
               * signal an error here, though... for now, we'll let caller
               * do that
               */
              if (id.isDefined()) {
                  ;
              } else {
                  /* Not defined, just need to upgrade, and possibly remove from
                   * the linked list.
                   */
                  id.markDefined(loc);
                  
                  /* Ok; if it was the first undefined, need to unlink it, as
                   * well as potentially next items.
                   */
                  if (id == mHead) {
                      do {
                          mHead = mHead.nextUndefined();
                      } while (mHead != null && mHead.isDefined());
                      
                      // Did we clear up all undefined ids?
                      if (mHead == null) {
                          mTail = null;
                      }
                  }
              }
          }
  
          return id;
      }
docs: Method called when an id definition is encountered. If so, need
  to check if specified id entry (ref or definiton) exists. If not,
  need to add the definition marker. If it does exist, need to
  'upgrade it', if it was a reference marker; otherwise need to
  just return the old entry, and expect caller to check for dups
  and report the error.