Fan.Sys.List.intersection C# (CSharp) Method

intersection() public method

public intersection ( List that ) : List
that List
return List
        public List intersection(List that)
        {
            // put other list into map
              Hashtable dups = new Hashtable(that.m_size*3);
              bool hasNull = false;
              for (int i=0; i<that.m_size; ++i)
              {
            object v = that.m_values[i];
            if (v == null) hasNull = true;
            else dups[v] = this;
              }

              // now walk this list and accumulate
              // everything found in the dups map
              List acc = new List(m_of, m_size);
              for (int i=0; i<m_size; i++)
              {
            object v = m_values[i];
            if (v == null && hasNull)
            {
              acc.add(v);
              hasNull = false;
            }
            else if (v != null && dups[v] != null)
            {
              acc.add(v);
              dups.Remove(v);
            }
              }
              return acc;
        }