~ubuntu-branches/ubuntu/vivid/quantlib-swig/vivid

« back to all changes in this revision

Viewing changes to CSharp/csharp/YieldTermStructureVector.cs

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2009-12-03 17:01:53 UTC
  • mfrom: (1.1.9 upstream) (2.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20091203170153-x5yrwybjsl2q11vw
* New upstream release

* debian/control: Updated Standards-Version: to current value

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ----------------------------------------------------------------------------
2
 
 * This file was automatically generated by SWIG (http://www.swig.org).
3
 
 * Version 1.3.36
4
 
 *
5
 
 * Do not make changes to this file unless you know what you are doing--modify
6
 
 * the SWIG interface file instead.
7
 
 * ----------------------------------------------------------------------------- */
8
 
 
9
 
namespace QuantLib {
10
 
 
11
 
using System;
12
 
using System.Runtime.InteropServices;
13
 
 
14
 
public class YieldTermStructureVector : IDisposable, System.Collections.IEnumerable {
15
 
  private HandleRef swigCPtr;
16
 
  protected bool swigCMemOwn;
17
 
 
18
 
  internal YieldTermStructureVector(IntPtr cPtr, bool cMemoryOwn) {
19
 
    swigCMemOwn = cMemoryOwn;
20
 
    swigCPtr = new HandleRef(this, cPtr);
21
 
  }
22
 
 
23
 
  internal static HandleRef getCPtr(YieldTermStructureVector obj) {
24
 
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
25
 
  }
26
 
 
27
 
  ~YieldTermStructureVector() {
28
 
    Dispose();
29
 
  }
30
 
 
31
 
  public virtual void Dispose() {
32
 
    lock(this) {
33
 
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
34
 
        swigCMemOwn = false;
35
 
        NQuantLibcPINVOKE.delete_YieldTermStructureVector(swigCPtr);
36
 
      }
37
 
      swigCPtr = new HandleRef(null, IntPtr.Zero);
38
 
      GC.SuppressFinalize(this);
39
 
    }
40
 
  }
41
 
 
42
 
  public YieldTermStructureVector(System.Collections.ICollection c) : this() {
43
 
    if (c == null)
44
 
      throw new ArgumentNullException("c");
45
 
    foreach (YieldTermStructureHandle element in c) {
46
 
      this.Add(element);
47
 
    }
48
 
  }
49
 
 
50
 
  public bool IsFixedSize {
51
 
    get {
52
 
      return false;
53
 
    }
54
 
  }
55
 
 
56
 
  public bool IsReadOnly {
57
 
    get {
58
 
      return false;
59
 
    }
60
 
  }
61
 
 
62
 
  public YieldTermStructureHandle this[int index]  {
63
 
    get {
64
 
      return getitem(index);
65
 
    }
66
 
    set {
67
 
      setitem(index, value);
68
 
    }
69
 
  }
70
 
 
71
 
  public int Capacity {
72
 
    get {
73
 
      return (int)capacity();
74
 
    }
75
 
    set {
76
 
      if (value < size())
77
 
        throw new ArgumentOutOfRangeException("Capacity");
78
 
      reserve((uint)value);
79
 
    }
80
 
  }
81
 
 
82
 
  public int Count {
83
 
    get {
84
 
      return (int)size();
85
 
    }
86
 
  }
87
 
 
88
 
  public bool IsSynchronized {
89
 
    get {
90
 
      return false;
91
 
    }
92
 
  }
93
 
 
94
 
  public void CopyTo(System.Array array) {
95
 
    CopyTo(0, array, 0, this.Count);
96
 
  }
97
 
 
98
 
  public void CopyTo(System.Array array, int arrayIndex) {
99
 
    CopyTo(0, array, arrayIndex, this.Count);
100
 
  }
101
 
 
102
 
  public void CopyTo(int index, System.Array array, int arrayIndex, int count) {
103
 
    if (array == null)
104
 
      throw new ArgumentNullException("array");
105
 
    if (index < 0)
106
 
      throw new ArgumentOutOfRangeException("index", "Value is less than zero");
107
 
    if (arrayIndex < 0)
108
 
      throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
109
 
    if (count < 0)
110
 
      throw new ArgumentOutOfRangeException("count", "Value is less than zero");
111
 
    if (array.Rank > 1)
112
 
      throw new ArgumentException("Multi dimensional array.");
113
 
    if (index+count > this.Count || arrayIndex+count > array.Length)
114
 
      throw new ArgumentException("Number of elements to copy is too large.");
115
 
    for (int i=0; i<count; i++)
116
 
      array.SetValue(getitemcopy(index+i), arrayIndex+i);
117
 
  }
118
 
 
119
 
  // Type-safe version of IEnumerable.GetEnumerator
120
 
  System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
121
 
    return new YieldTermStructureVectorEnumerator(this);
122
 
  }
123
 
 
124
 
  public YieldTermStructureVectorEnumerator GetEnumerator() {
125
 
    return new YieldTermStructureVectorEnumerator(this);
126
 
  }
127
 
 
128
 
  // Type-safe enumerator
129
 
  /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
130
 
  /// whenever the collection is modified. This has been done for changes in the size of the
131
 
  /// collection but not when one of the elements of the collection is modified as it is a bit
132
 
  /// tricky to detect unmanaged code that modifies the collection under our feet.
133
 
  public sealed class YieldTermStructureVectorEnumerator : System.Collections.IEnumerator {
134
 
    private YieldTermStructureVector collectionRef;
135
 
    private int currentIndex;
136
 
    private object currentObject;
137
 
    private int currentSize;
138
 
 
139
 
    public YieldTermStructureVectorEnumerator(YieldTermStructureVector collection) {
140
 
      collectionRef = collection;
141
 
      currentIndex = -1;
142
 
      currentObject = null;
143
 
      currentSize = collectionRef.Count;
144
 
    }
145
 
 
146
 
    // Type-safe iterator Current
147
 
    public YieldTermStructureHandle Current {
148
 
      get {
149
 
        if (currentIndex == -1)
150
 
          throw new InvalidOperationException("Enumeration not started.");
151
 
        if (currentIndex > currentSize - 1)
152
 
          throw new InvalidOperationException("Enumeration finished.");
153
 
        if (currentObject == null)
154
 
          throw new InvalidOperationException("Collection modified.");
155
 
        return (YieldTermStructureHandle)currentObject;
156
 
      }
157
 
    }
158
 
 
159
 
    // Type-unsafe IEnumerator.Current
160
 
    object System.Collections.IEnumerator.Current {
161
 
      get {
162
 
        return Current;
163
 
      }
164
 
    }
165
 
 
166
 
    public bool MoveNext() {
167
 
      int size = collectionRef.Count;
168
 
      bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
169
 
      if (moveOkay) {
170
 
        currentIndex++;
171
 
        currentObject = collectionRef[currentIndex];
172
 
      } else {
173
 
        currentObject = null;
174
 
      }
175
 
      return moveOkay;
176
 
    }
177
 
 
178
 
    public void Reset() {
179
 
      currentIndex = -1;
180
 
      currentObject = null;
181
 
      if (collectionRef.Count != currentSize) {
182
 
        throw new InvalidOperationException("Collection modified.");
183
 
      }
184
 
    }
185
 
  }
186
 
 
187
 
  public void Clear() {
188
 
    NQuantLibcPINVOKE.YieldTermStructureVector_Clear(swigCPtr);
189
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
190
 
  }
191
 
 
192
 
  public void Add(YieldTermStructureHandle x) {
193
 
    NQuantLibcPINVOKE.YieldTermStructureVector_Add(swigCPtr, YieldTermStructureHandle.getCPtr(x));
194
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
195
 
  }
196
 
 
197
 
  private uint size() {
198
 
    uint ret = NQuantLibcPINVOKE.YieldTermStructureVector_size(swigCPtr);
199
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
200
 
    return ret;
201
 
  }
202
 
 
203
 
  private uint capacity() {
204
 
    uint ret = NQuantLibcPINVOKE.YieldTermStructureVector_capacity(swigCPtr);
205
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
206
 
    return ret;
207
 
  }
208
 
 
209
 
  private void reserve(uint n) {
210
 
    NQuantLibcPINVOKE.YieldTermStructureVector_reserve(swigCPtr, n);
211
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
212
 
  }
213
 
 
214
 
  public YieldTermStructureVector() : this(NQuantLibcPINVOKE.new_YieldTermStructureVector__SWIG_0(), true) {
215
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
216
 
  }
217
 
 
218
 
  public YieldTermStructureVector(int capacity) : this(NQuantLibcPINVOKE.new_YieldTermStructureVector__SWIG_1(capacity), true) {
219
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
220
 
  }
221
 
 
222
 
  private YieldTermStructureHandle getitemcopy(int index) {
223
 
    YieldTermStructureHandle ret = new YieldTermStructureHandle(NQuantLibcPINVOKE.YieldTermStructureVector_getitemcopy(swigCPtr, index), true);
224
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
225
 
    return ret;
226
 
  }
227
 
 
228
 
  private YieldTermStructureHandle getitem(int index) {
229
 
    YieldTermStructureHandle ret = new YieldTermStructureHandle(NQuantLibcPINVOKE.YieldTermStructureVector_getitem(swigCPtr, index), false);
230
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
231
 
    return ret;
232
 
  }
233
 
 
234
 
  private void setitem(int index, YieldTermStructureHandle val) {
235
 
    NQuantLibcPINVOKE.YieldTermStructureVector_setitem(swigCPtr, index, YieldTermStructureHandle.getCPtr(val));
236
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
237
 
  }
238
 
 
239
 
  public void AddRange(YieldTermStructureVector values) {
240
 
    NQuantLibcPINVOKE.YieldTermStructureVector_AddRange(swigCPtr, YieldTermStructureVector.getCPtr(values));
241
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
242
 
  }
243
 
 
244
 
  public YieldTermStructureVector GetRange(int index, int count) {
245
 
    IntPtr cPtr = NQuantLibcPINVOKE.YieldTermStructureVector_GetRange(swigCPtr, index, count);
246
 
    YieldTermStructureVector ret = (cPtr == IntPtr.Zero) ? null : new YieldTermStructureVector(cPtr, true);
247
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
248
 
    return ret;
249
 
  }
250
 
 
251
 
  public void Insert(int index, YieldTermStructureHandle x) {
252
 
    NQuantLibcPINVOKE.YieldTermStructureVector_Insert(swigCPtr, index, YieldTermStructureHandle.getCPtr(x));
253
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
254
 
  }
255
 
 
256
 
  public void InsertRange(int index, YieldTermStructureVector values) {
257
 
    NQuantLibcPINVOKE.YieldTermStructureVector_InsertRange(swigCPtr, index, YieldTermStructureVector.getCPtr(values));
258
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
259
 
  }
260
 
 
261
 
  public void RemoveAt(int index) {
262
 
    NQuantLibcPINVOKE.YieldTermStructureVector_RemoveAt(swigCPtr, index);
263
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
264
 
  }
265
 
 
266
 
  public void RemoveRange(int index, int count) {
267
 
    NQuantLibcPINVOKE.YieldTermStructureVector_RemoveRange(swigCPtr, index, count);
268
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
269
 
  }
270
 
 
271
 
  public static YieldTermStructureVector Repeat(YieldTermStructureHandle value, int count) {
272
 
    IntPtr cPtr = NQuantLibcPINVOKE.YieldTermStructureVector_Repeat(YieldTermStructureHandle.getCPtr(value), count);
273
 
    YieldTermStructureVector ret = (cPtr == IntPtr.Zero) ? null : new YieldTermStructureVector(cPtr, true);
274
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
275
 
    return ret;
276
 
  }
277
 
 
278
 
  public void Reverse() {
279
 
    NQuantLibcPINVOKE.YieldTermStructureVector_Reverse__SWIG_0(swigCPtr);
280
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
281
 
  }
282
 
 
283
 
  public void Reverse(int index, int count) {
284
 
    NQuantLibcPINVOKE.YieldTermStructureVector_Reverse__SWIG_1(swigCPtr, index, count);
285
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
286
 
  }
287
 
 
288
 
  public void SetRange(int index, YieldTermStructureVector values) {
289
 
    NQuantLibcPINVOKE.YieldTermStructureVector_SetRange(swigCPtr, index, YieldTermStructureVector.getCPtr(values));
290
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
291
 
  }
292
 
 
293
 
  public bool Contains(YieldTermStructureHandle value) {
294
 
    bool ret = NQuantLibcPINVOKE.YieldTermStructureVector_Contains(swigCPtr, YieldTermStructureHandle.getCPtr(value));
295
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
296
 
    return ret;
297
 
  }
298
 
 
299
 
  public int IndexOf(YieldTermStructureHandle value) {
300
 
    int ret = NQuantLibcPINVOKE.YieldTermStructureVector_IndexOf(swigCPtr, YieldTermStructureHandle.getCPtr(value));
301
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
302
 
    return ret;
303
 
  }
304
 
 
305
 
  public int LastIndexOf(YieldTermStructureHandle value) {
306
 
    int ret = NQuantLibcPINVOKE.YieldTermStructureVector_LastIndexOf(swigCPtr, YieldTermStructureHandle.getCPtr(value));
307
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
308
 
    return ret;
309
 
  }
310
 
 
311
 
  public void Remove(YieldTermStructureHandle value) {
312
 
    NQuantLibcPINVOKE.YieldTermStructureVector_Remove(swigCPtr, YieldTermStructureHandle.getCPtr(value));
313
 
    if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
314
 
  }
315
 
 
316
 
}
317
 
 
318
 
}