Free cookie consent management tool by TermsFeed Policy Generator

Changeset 732


Ignore:
Timestamp:
11/11/08 12:20:45 (16 years ago)
Author:
gkronber
Message:

fixed #337 (TryXXX methods in ConstrainedItemList do not return violated constraints correctly)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/ConstrainedItemList.cs

    r347 r732  
    114114    public bool TryInsert(int index, IItem item, out ICollection<IConstraint> violatedConstraints) {
    115115      list.Insert(index, item);
     116      violatedConstraints = new List<IConstraint>();
    116117      if (!suspendConstraintCheck && IsValid(out violatedConstraints)) {
    117118        OnItemAdded(item, index);
    118119        return true;
    119120      } else {
    120         violatedConstraints = new List<IConstraint>();
    121121        list.RemoveAt(index);
    122122        return false;
     
    127127      IItem item = list[index];
    128128      list.RemoveAt(index);
     129      violatedConstraints = new List<IConstraint>();
    129130      if (!suspendConstraintCheck && IsValid(out violatedConstraints)) {
    130131        OnItemRemoved(item, index);
    131132        return true;
    132133      } else {
    133         violatedConstraints = new List<IConstraint>();
    134134        list.Insert(index, item);
    135135        return false;
     
    144144      IItem backup = this[index];
    145145      list[index] = item;
    146       if (!suspendConstraintCheck && IsValid(out violatedConstraints)) {
    147         return true;
    148       } else {
    149         violatedConstraints = new List<IConstraint>();
     146      violatedConstraints = new List<IConstraint>();
     147      if (!suspendConstraintCheck && IsValid(out violatedConstraints)) {
     148        return true;
     149      } else {
    150150        list[index] = backup;
    151151        return false;
     
    155155    public bool TryAdd(IItem item, out ICollection<IConstraint> violatedConstraints) {
    156156      list.Add(item);
     157      violatedConstraints = new List<IConstraint>();
    157158      if (!suspendConstraintCheck && IsValid(out violatedConstraints)) {
    158159        OnItemAdded(item, list.Count - 1);
    159160        return true;
    160161      } else {
    161         violatedConstraints = new List<IConstraint>();
    162162        list.RemoveAt(list.Count - 1);
    163163        return false;
Note: See TracChangeset for help on using the changeset viewer.