Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/14/16 14:57:02 (8 years ago)
Author:
mkommend
Message:

#2589: Added resizable option in ValueTypeArray and refactored the array implementations and interfaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeArray.cs

    r12012 r13695  
    3333  [Item("ValueTypeArray", "An abstract base class for representing arrays of value types.")]
    3434  [StorableClass]
    35   public abstract class ValueTypeArray<T> : Item, IEnumerable<T> where T : struct {
     35  public abstract class ValueTypeArray<T> : Item, IValueTypeArray<T> where T : struct {
    3636    private const int maximumToStringLength = 100;
    3737
     
    7575      #endregion
    7676    }
     77
     78    [Storable]
     79    protected bool resizable = true;
     80    public bool Resizable {
     81      get { return resizable; }
     82      set {
     83        if (resizable != value) {
     84          resizable = value;
     85          OnResizableChanged();
     86        }
     87      }
     88    }
     89
     90
    7791    public virtual T this[int index] {
    7892      get { return array[index]; }
     
    103117      this.array = (T[])original.array.Clone();
    104118      this.readOnly = original.readOnly;
     119      this.resizable = original.resizable;
    105120      this.elementNames = new List<string>(original.elementNames);
    106121    }
     
    108123      array = new T[0];
    109124      readOnly = false;
     125      resizable = true;
    110126      elementNames = new List<string>();
    111127    }
     
    113129      array = new T[length];
    114130      readOnly = false;
     131      resizable = true;
    115132      elementNames = new List<string>();
    116133    }
     
    119136      array = (T[])elements.Clone();
    120137      readOnly = false;
     138      resizable = true;
    121139      elementNames = new List<string>();
    122140    }
    123141
    124     public virtual ValueTypeArray<T> AsReadOnly() {
     142    public virtual IValueTypeArray AsReadOnly() {
    125143      ValueTypeArray<T> readOnlyValueTypeArray = (ValueTypeArray<T>)this.Clone();
    126144      readOnlyValueTypeArray.readOnly = true;
     
    153171    }
    154172
     173    public event EventHandler ResizableChanged;
     174    protected virtual void OnResizableChanged() {
     175      EventHandler handler = ResizableChanged;
     176      if (handler != null)
     177        handler(this, EventArgs.Empty);
     178    }
    155179    public event EventHandler ElementNamesChanged;
    156180    protected virtual void OnElementNamesChanged() {
Note: See TracChangeset for help on using the changeset viewer.