Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8215


Ignore:
Timestamp:
07/04/12 17:09:59 (12 years ago)
Author:
bburlacu
Message:

#1265: Introduced a hash for primitives in order to improve lookup performance (Contains method).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/Primitives/Group.cs

    r4776 r8215  
    2323using System.Collections.Generic;
    2424using System.Collections.ObjectModel;
    25 using System.Text;
    2625using System.Drawing;
    2726using System.Windows.Forms;
     
    3029  public class Group : PrimitiveBase, IGroup {
    3130    private IList<IPrimitive> myPrimitives;
     31    private HashSet<IPrimitive> myPrimitivesLookup;
    3232    public virtual ReadOnlyCollection<IPrimitive> Primitives {
    3333      get { return new ReadOnlyCollection<IPrimitive>(myPrimitives); }
     
    5757      : base(chart) {
    5858      myPrimitives = new List<IPrimitive>();
     59      myPrimitivesLookup = new HashSet<IPrimitive>();
    5960    }
    6061
     
    6465
    6566      myPrimitives.Insert(0, primitive);
     67      myPrimitivesLookup.Add(primitive);
    6668      primitive.Group = this;
    6769      primitive.Update += new EventHandler(primitive_Update);
     
    7476
    7577        myPrimitives.Insert(0, primitive);
     78        myPrimitivesLookup.Add(primitive);
    7679        primitive.Group = this;
    7780        primitive.Update += new EventHandler(primitive_Update);
     
    8083    }
    8184    public virtual bool Contains(IPrimitive primitive) {
    82       return myPrimitives.Contains(primitive);
     85      return myPrimitivesLookup.Contains(primitive);
    8386    }
    8487    public virtual bool Remove(IPrimitive primitive) {
     
    98101      }
    99102      myPrimitives.Clear();
     103      myPrimitivesLookup.Clear();
    100104      OnUpdate();
    101105    }
Note: See TracChangeset for help on using the changeset viewer.