Skip to content

Commit 9ee38f3

Browse files
committed
Merge branch 'addax'
2 parents 8331cba + f59ae8a commit 9ee38f3

22 files changed

+4807
-1279
lines changed

buildLauncher.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ def __collect(self, path):
1717

1818
for root, dirs, files in os.walk(path):
1919
for fileName in files:
20-
with open(os.path.join(root, fileName), 'r') as f:
21-
for line in f:
22-
outcome = re.findall(pattern, line)
23-
for e in outcome:
24-
collected.append(e)
20+
ext = os.path.splitext(fileName)[1]
21+
22+
if ext == '.ts':
23+
with open(os.path.join(root, fileName), 'r') as f:
24+
for line in f:
25+
outcome = re.findall(pattern, line)
26+
for e in outcome:
27+
collected.append(e)
2528

2629
return collected
2730

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Ludivine",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"devDependencies": {
55
"grunt": "~0.4.5",
66
"grunt-contrib-clean": "~0.6.0",

src/Guid.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
*/
77
class Guid {
88
//region Fields
9-
9+
1010
//endregion Fields
11-
11+
1212
//region Constructors
13-
13+
1414
//endregion Constructors
15-
15+
1616
//region Methods
17-
17+
1818
//region Private Methods
19-
19+
2020
/**
2121
* Returns a random string using provided charset
2222
* @param {number} length Desired length
@@ -41,9 +41,9 @@ class Guid {
4141
}
4242

4343
//endregion Private Methods
44-
44+
4545
//region Public Methods
46-
46+
4747
/**
4848
* Produces a new guid
4949
* @return {string} [description]
@@ -66,6 +66,6 @@ class Guid {
6666
}
6767

6868
//endregion Public Methods
69-
69+
7070
//endregion Methods
7171
}

src/collections/impl/ArrayList.ts

Lines changed: 66 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class ArrayList<T> implements IList<T> {
1111
* Inner content
1212
*/
1313
private _content : Array<T>;
14-
14+
1515
//endregion Fields
16-
16+
1717
//region Constructors
1818

1919
/**
@@ -27,15 +27,15 @@ class ArrayList<T> implements IList<T> {
2727
source.forEach(x => this.add(x));
2828
}
2929
}
30-
30+
3131
//endregion Constructors
32-
32+
3333
//region Methods
34-
34+
3535
//region Private Methods
36-
36+
3737
//endregion Private Methods
38-
38+
3939
//region Public Methods
4040

4141
//region IList
@@ -173,7 +173,7 @@ class ArrayList<T> implements IList<T> {
173173
a = new Array<T>();
174174
this.forEach(e => a.push(e));
175175
CollectionUtils.ArrayUtils.sort(a, getter);
176-
176+
177177
for (var i = 0; i < a.length; i++) {
178178
outcome.add(a[i]);
179179
}
@@ -194,7 +194,7 @@ class ArrayList<T> implements IList<T> {
194194
a = new Array<T>();
195195
this.forEach(e => a.push(e));
196196
CollectionUtils.ArrayUtils.sort(a, getter, false);
197-
197+
198198
for (var i = 0; i < a.length; i++) {
199199
outcome.add(a[i]);
200200
}
@@ -218,6 +218,14 @@ class ArrayList<T> implements IList<T> {
218218

219219
//region ICollection
220220

221+
average(getter : Func<T, number>) : number {
222+
return CollectionUtils.CollectionHelper.average(this, getter);
223+
}
224+
225+
exists(selector : Func<T, boolean>) : boolean {
226+
return this.find(selector) !== null;
227+
}
228+
221229
find(selector : Func<T, boolean>) : T {
222230
var size : number;
223231

@@ -245,67 +253,36 @@ class ArrayList<T> implements IList<T> {
245253
}
246254
}
247255

248-
map(action : Func<T, T>) : ICollection<T> {
256+
intersect(collection : ICollection<T>) : ICollection<T> {
249257
var outcome : ArrayList<T>;
250258

251259
outcome = new ArrayList<T>();
252-
this.forEach(e => outcome.add(action(e)));
253-
254-
return outcome;
255-
}
256-
257-
max(getter : Func<T, number>) : T {
258-
var max : number;
259-
var current : T;
260-
261-
if (this.getLength() === 0) {
262-
return null;
263-
}
264-
265-
current = this.getAt(0);
266-
max = getter(current);
267-
268260
this.forEach(
269-
(e) => {
270-
var value : number;
271-
272-
value = getter(e);
273-
274-
if (value > max) {
275-
max = value;
276-
current = e;
261+
(x) => {
262+
if (collection.exists(e => e === x)) {
263+
outcome.add(x);
277264
}
278265
}
279266
);
280267

281-
return current;
268+
return outcome;
282269
}
283270

284-
min(getter : Func<T, number>) : T {
285-
var min : number;
286-
var current : T;
287-
288-
if (this.getLength() === 0) {
289-
return null;
290-
}
291-
292-
current = this.getAt(0);
293-
min = getter(current);
271+
map(action : Func<T, T>) : ICollection<T> {
272+
var outcome : ArrayList<T>;
294273

295-
this.forEach(
296-
(e) => {
297-
var value : number;
274+
outcome = new ArrayList<T>();
275+
this.forEach(e => outcome.add(action(e)));
298276

299-
value = getter(e);
277+
return outcome;
278+
}
300279

301-
if (value < min) {
302-
min = value;
303-
current = e;
304-
}
305-
}
306-
);
280+
max(getter : Func<T, number>) : T {
281+
return CollectionUtils.CollectionHelper.max(this, getter);
282+
}
307283

308-
return current;
284+
min(getter : Func<T, number>) : T {
285+
return CollectionUtils.CollectionHelper.min(this, getter);
309286
}
310287

311288
select(selector : Func<T, boolean>) : ICollection<T> {
@@ -325,39 +302,54 @@ class ArrayList<T> implements IList<T> {
325302
}
326303

327304
sum(getter : Func<T, number>) : number {
328-
var acc : number;
329-
330-
acc = 0;
331-
this.forEach(e => acc += getter(e));
332-
333-
return acc;
305+
return CollectionUtils.CollectionHelper.sum(this, getter);
334306
}
335307

336308
toArray() : Array<T> {
337-
var outcome : Array<T>;
309+
return CollectionUtils.CollectionHelper.toArray(this);
310+
}
338311

339-
outcome = new Array<T>();
340-
this.forEach(x => outcome.push(x));
312+
toDictionary<K, V>(keyGetter : Func<T, K>, valueGetter : Func<T, V>) : IDictionary<K, V> {
313+
return CollectionUtils.CollectionHelper.toDictionary(this, keyGetter, valueGetter);
314+
}
341315

342-
return outcome;
316+
toList() : IList<T> {
317+
return CollectionUtils.CollectionHelper.toList(this);
343318
}
344319

345-
toDictionary<K, V>(keyGetter : Func<T, K>, valueGetter : Func<T, V>) : IDictionary<K, V> {
346-
var outcome : IDictionary<K, V>;
320+
union(collection : ICollection<T>) : ICollection<T> {
321+
var outcome : ArrayList<T>;
347322

348-
outcome = new Dictionary<K, V>();
349-
this.forEach(x => outcome.add(keyGetter(x), valueGetter(x)));
323+
outcome = new ArrayList<T>(this);
324+
collection.forEach(
325+
(x) => {
326+
if (!this.exists(e => e === x)) {
327+
outcome.add(x);
328+
}
329+
}
330+
);
350331

351332
return outcome;
352333
}
353334

354-
toList() : IList<T> {
355-
return new ArrayList<T>(this);
335+
uniq() : ICollection<T> {
336+
var outcome : ArrayList<T>;
337+
338+
outcome = new ArrayList<T>();
339+
this.forEach(
340+
(x) => {
341+
if (!outcome.exists(e => e === x)) {
342+
outcome.add(x);
343+
}
344+
}
345+
);
346+
347+
return outcome;
356348
}
357349

358350
//endregion ICollection
359-
351+
360352
//endregion Public Methods
361-
353+
362354
//endregion Methods
363355
}

0 commit comments

Comments
 (0)