Skip to content

Commit b37dfab

Browse files
Merge pull request #1 from ronzano/master
Bugfix for inclusion in multiple files
2 parents dc9c14b + f826e95 commit b37dfab

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

src/ListLib.h

+29-28
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/***************************************************
2-
Copyright (c) 2017 Luis Llamas
3-
(www.luisllamas.es)
4-
5-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6-
7-
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
1+
/***************************************************
2+
Copyright (c) 2017 Luis Llamas
3+
(www.luisllamas.es)
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
88
****************************************************/
99

1010
#ifndef _ListLib_h
@@ -21,7 +21,7 @@ class List
2121
{
2222
public:
2323
List();
24-
List(size_t capacity);
24+
List(size_t capacity);
2525
~List();
2626

2727
size_t Capacity() const;
@@ -38,9 +38,9 @@ class List
3838
void Add(T item);
3939
void AddRange(T* items, size_t numItems);
4040

41-
void Insert(T item);
42-
void Insert(size_t index, T item);
43-
void InsertRange(T* items, size_t numItems);
41+
void Insert(T item);
42+
void Insert(size_t index, T item);
43+
void InsertRange(T* items, size_t numItems);
4444
void InsertRange(size_t index, T* items, size_t numItems);
4545

4646
void RemoveFirst();
@@ -76,7 +76,6 @@ class List
7676
void reserve(size_t size);
7777
void resize(size_t size);
7878
};
79-
#endif
8079

8180

8281
template <typename T>
@@ -90,12 +89,12 @@ List<T>::List(size_t capacity)
9089
{
9190
_capacity = capacity;
9291
_items = new T[_capacity];
93-
}
94-
95-
template <typename T>
96-
List<T>::~List()
97-
{
98-
delete[] _items;
92+
}
93+
94+
template <typename T>
95+
List<T>::~List()
96+
{
97+
delete[] _items;
9998
}
10099

101100
template <typename T>
@@ -152,15 +151,15 @@ void List<T>::Insert(T item)
152151
shift(0, 1);
153152
_items[0] = item;
154153
}
155-
156-
template <typename T>
157-
void List<T>::InsertRange(T* items, size_t numItems)
158-
{
159-
_count += numItems;
160-
reserve(_count);
161-
shift(0, numItems);
162-
memmove(_items, items, numItems * sizeof(T));
163-
}
154+
155+
template <typename T>
156+
void List<T>::InsertRange(T* items, size_t numItems)
157+
{
158+
_count += numItems;
159+
reserve(_count);
160+
shift(0, numItems);
161+
memmove(_items, items, numItems * sizeof(T));
162+
}
164163

165164
template <typename T>
166165
void List<T>::Insert(size_t index, T item)
@@ -360,4 +359,6 @@ void List<T>::resize(size_t size)
360359
delete[] _items;
361360
_capacity = size;
362361
_items = newItems;
363-
}
362+
}
363+
364+
#endif

0 commit comments

Comments
 (0)