Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit a0e4c8d

Browse files
committed
Should be functional with all STL algorithms.
1 parent 79ad977 commit a0e4c8d

File tree

1 file changed

+5
-69
lines changed

1 file changed

+5
-69
lines changed

sion-vector.h

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,7 @@ namespace sion
2222
size_t length;
2323

2424
public:
25-
template<class T>
26-
class vector_iter
27-
{
28-
private:
29-
T* pointee;
30-
31-
public:
32-
using iterator_category = std::random_access_iterator_tag;
33-
using value_type = T;
34-
using difference_type = std::ptrdiff_t;
35-
using pointer = T*;
36-
using reference = T&;
37-
38-
vector_iter()
39-
{
40-
pointee = nullptr;
41-
}
42-
43-
vector_iter(T* ptr)
44-
{
45-
pointee = ptr;
46-
}
47-
48-
T& operator *()
49-
{
50-
return *pointee;
51-
}
52-
53-
T* operator ->()
54-
{
55-
return pointee;
56-
}
57-
58-
vector_iter<T>& operator ++()
59-
{
60-
++pointee;
61-
return *this;
62-
}
63-
64-
vector_iter<T>& operator --()
65-
{
66-
--pointee;
67-
return *this;
68-
}
69-
70-
vector_iter<T>& operator +(int rhs)
71-
{
72-
pointee = pointee + rhs;
73-
return *this;
74-
}
75-
76-
vector_iter<T>& operator -(int rhs)
77-
{
78-
pointee = pointee - rhs;
79-
return * this;
80-
}
81-
82-
bool operator ==(vector_iter<T>& rhs)
83-
{
84-
return this.pointee == rhs.pointee;
85-
}
86-
};
87-
88-
89-
using iterator = vector_iter<type>;
25+
using iterator = type*;
9026

9127
vector()
9228
{
@@ -162,14 +98,14 @@ namespace sion
16298
}
16399
}
164100

165-
iterator begin()
101+
type* begin()
166102
{
167-
return iterator(&elements[0]);
103+
return &elements[0];
168104
}
169105

170-
iterator end()
106+
type* end()
171107
{
172-
return iterator(&elements[length - 1] + 1);
108+
return &elements[length - 1] + 1;
173109
}
174110

175111
type& operator[](size_t index)

0 commit comments

Comments
 (0)