Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core/3.3/ExecutionContextCollection.cs @ 2664

Last change on this file since 2664 was 2664, checked in by swagner, 14 years ago

Abandoned policy that the names of all abstract base classes have to end in "Base" (#95)

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Xml;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Core {
29  public class ExecutionContextCollection : DeepCloneable, IList<ExecutionContext> {
30    [Storable]
31    private IList<ExecutionContext> contexts;
32
33    [Storable]
34    private bool parallel;
35    public bool Parallel {
36      get { return parallel; }
37      set { parallel = value; }
38    }
39
40    public ExecutionContextCollection() {
41      contexts = new List<ExecutionContext>();
42      parallel = false;
43    }
44    public ExecutionContextCollection(IEnumerable<ExecutionContext> collection) {
45      contexts = new List<ExecutionContext>(collection);
46      parallel = false;
47    }
48    public ExecutionContextCollection(params ExecutionContext[] list) {
49      contexts = new List<ExecutionContext>(list);
50      parallel = false;
51    }
52
53    public override IDeepCloneable Clone(Cloner cloner) {
54      ExecutionContextCollection clone = new ExecutionContextCollection();
55      cloner.RegisterClonedObject(this, clone);
56      clone.parallel = parallel;
57      for (int i = 0; i < contexts.Count; i++)
58        clone.contexts.Add((ExecutionContext)cloner.Clone(contexts[i]));
59      return clone;
60    }
61
62    #region IList<ExecutionContext> Members
63    public int IndexOf(ExecutionContext item) {
64      return contexts.IndexOf(item);
65    }
66    public void Insert(int index, ExecutionContext item) {
67      contexts.Insert(index, item);
68    }
69    public void RemoveAt(int index) {
70      contexts.RemoveAt(index);
71    }
72    public ExecutionContext this[int index] {
73      get { return contexts[index]; }
74      set { contexts[index] = value; }
75    }
76    #endregion
77
78    #region ICollection<ExecutionContext> Members
79    public void Add(ExecutionContext item) {
80      contexts.Add(item);
81    }
82    public void Clear() {
83      contexts.Clear();
84    }
85    public bool Contains(ExecutionContext item) {
86      return contexts.Contains(item);
87    }
88    public void CopyTo(ExecutionContext[] array, int arrayIndex) {
89      contexts.CopyTo(array, arrayIndex);
90    }
91    public int Count {
92      get { return contexts.Count; }
93    }
94    public bool IsReadOnly {
95      get { return contexts.IsReadOnly; }
96    }
97    public bool Remove(ExecutionContext item) {
98      return contexts.Remove(item);
99    }
100    #endregion
101
102    #region IEnumerable<ExecutionContext> Members
103    public IEnumerator<ExecutionContext> GetEnumerator() {
104      return contexts.GetEnumerator();
105    }
106    #endregion
107
108    #region IEnumerable Members
109    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
110      return contexts.GetEnumerator();
111    }
112    #endregion
113  }
114}
Note: See TracBrowser for help on using the repository browser.