-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmallIntVector.cs
More file actions
58 lines (48 loc) · 1.04 KB
/
Copy pathSmallIntVector.cs
File metadata and controls
58 lines (48 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#region Using directives
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
#endregion
namespace PariSharp
{
public sealed partial class SmallIntVector: PariObject, IReadOnlyList<int>, IEnumerable<int>
{
public override PariType Type
{
get { return PariType.SmallIntVector; }
}
#region IReadOnlyList implementation
public int Count
{
get { return glength(Address); }
}
public int this[int index]
{
get
{
unsafe { return *(int*)(Address + ((index + 1) << 2)).ToPointer(); }
}
}
public IEnumerator<int> GetEnumerator()
{
return new Enumerator(this);
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(this);
}
#endregion
public int[] ToArray()
{
int count = Count;
int[] array = new int[count];
for (int i = 0; i < count; ++i)
array[i] = this[i];
return array;
}
#region External PARI functions
#endregion
internal SmallIntVector(IntPtr address): base(address) {}
}
}