IncludeCPP 3.4.10__py3-none-any.whl → 3.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,6 +64,14 @@ class DataStruct(list):
64
64
  return target_type(self[0])
65
65
  return None
66
66
 
67
+ def begin(self) -> int:
68
+ """Return iterator to beginning (C++ style)"""
69
+ return 0
70
+
71
+ def end(self) -> int:
72
+ """Return iterator to end (C++ style)"""
73
+ return len(self)
74
+
67
75
 
68
76
  class Stack(list):
69
77
  """Stack data structure (LIFO).
@@ -86,6 +94,11 @@ class Stack(list):
86
94
  self.append(item)
87
95
  return self
88
96
 
97
+ def push_back(self, item: Any) -> 'Stack':
98
+ """Push item onto stack (alias for push)"""
99
+ self.append(item)
100
+ return self
101
+
89
102
  def peek(self) -> Any:
90
103
  """View top item without removing"""
91
104
  return self[-1] if self else None
@@ -94,10 +107,53 @@ class Stack(list):
94
107
  """Check if stack is empty"""
95
108
  return len(self) == 0
96
109
 
110
+ def isEmpty(self) -> bool:
111
+ """Check if stack is empty (camelCase alias)"""
112
+ return len(self) == 0
113
+
97
114
  def size(self) -> int:
98
115
  """Return stack size"""
99
116
  return len(self)
100
117
 
118
+ def length(self) -> int:
119
+ """Return stack length (alias for size)"""
120
+ return len(self)
121
+
122
+ def contains(self, item: Any) -> bool:
123
+ """Check if stack contains item"""
124
+ return item in self
125
+
126
+ def indexOf(self, item: Any) -> int:
127
+ """Find index of item (-1 if not found)"""
128
+ try:
129
+ return self.index(item)
130
+ except ValueError:
131
+ return -1
132
+
133
+ def toArray(self) -> list:
134
+ """Convert stack to array"""
135
+ return list(self)
136
+
137
+ def swap(self) -> 'Stack':
138
+ """Swap top two elements"""
139
+ if len(self) >= 2:
140
+ self[-1], self[-2] = self[-2], self[-1]
141
+ return self
142
+
143
+ def dup(self) -> 'Stack':
144
+ """Duplicate top element"""
145
+ if self:
146
+ self.append(self[-1])
147
+ return self
148
+
149
+ def begin(self) -> int:
150
+ """Return iterator to beginning (C++ style)"""
151
+ return 0
152
+
153
+ def end(self) -> int:
154
+ """Return iterator to end (C++ style)"""
155
+ return len(self)
156
+
101
157
 
102
158
  class Vector(list):
103
159
  """Dynamic array (vector) data structure.
@@ -120,6 +176,24 @@ class Vector(list):
120
176
  self.append(item)
121
177
  return self
122
178
 
179
+ def push_back(self, item: Any) -> 'Vector':
180
+ """Add item to end (alias for push)"""
181
+ self.append(item)
182
+ return self
183
+
184
+ def push_front(self, item: Any) -> 'Vector':
185
+ """Add item to front"""
186
+ self.insert(0, item)
187
+ return self
188
+
189
+ def pop_back(self) -> Any:
190
+ """Remove and return last element"""
191
+ return self.pop() if self else None
192
+
193
+ def pop_front(self) -> Any:
194
+ """Remove and return first element"""
195
+ return self.pop(0) if self else None
196
+
123
197
  def at(self, index: int) -> Any:
124
198
  """Get item at index"""
125
199
  if 0 <= index < len(self):
@@ -136,10 +210,18 @@ class Vector(list):
136
210
  """Return vector size"""
137
211
  return len(self)
138
212
 
213
+ def length(self) -> int:
214
+ """Return vector length (alias for size)"""
215
+ return len(self)
216
+
139
217
  def empty(self) -> bool:
140
218
  """Check if vector is empty"""
141
219
  return len(self) == 0
142
220
 
221
+ def isEmpty(self) -> bool:
222
+ """Check if vector is empty (camelCase alias)"""
223
+ return len(self) == 0
224
+
143
225
  def front(self) -> Any:
144
226
  """Get first element"""
145
227
  return self[0] if self else None
@@ -148,6 +230,321 @@ class Vector(list):
148
230
  """Get last element"""
149
231
  return self[-1] if self else None
150
232
 
233
+ def contains(self, item: Any) -> bool:
234
+ """Check if vector contains item"""
235
+ return item in self
236
+
237
+ def indexOf(self, item: Any) -> int:
238
+ """Find index of item (-1 if not found)"""
239
+ try:
240
+ return self.index(item)
241
+ except ValueError:
242
+ return -1
243
+
244
+ def lastIndexOf(self, item: Any) -> int:
245
+ """Find last index of item (-1 if not found)"""
246
+ for i in range(len(self) - 1, -1, -1):
247
+ if self[i] == item:
248
+ return i
249
+ return -1
250
+
251
+ def find(self, predicate: Callable[[Any], bool]) -> Any:
252
+ """Find first item matching predicate"""
253
+ for item in self:
254
+ if callable(predicate) and predicate(item):
255
+ return item
256
+ elif item == predicate:
257
+ return item
258
+ return None
259
+
260
+ def findIndex(self, predicate: Callable[[Any], bool]) -> int:
261
+ """Find index of first item matching predicate"""
262
+ for i, item in enumerate(self):
263
+ if callable(predicate) and predicate(item):
264
+ return i
265
+ elif item == predicate:
266
+ return i
267
+ return -1
268
+
269
+ def slice(self, start: int, end: int = None) -> 'Vector':
270
+ """Return slice of vector"""
271
+ if end is None:
272
+ result = Vector(self._element_type)
273
+ result.extend(self[start:])
274
+ else:
275
+ result = Vector(self._element_type)
276
+ result.extend(self[start:end])
277
+ return result
278
+
279
+ def join(self, separator: str = ',') -> str:
280
+ """Join elements into string"""
281
+ return separator.join(str(item) for item in self)
282
+
283
+ def map(self, func: Callable[[Any], Any]) -> 'Vector':
284
+ """Apply function to all elements"""
285
+ result = Vector(self._element_type)
286
+ result.extend(func(item) for item in self)
287
+ return result
288
+
289
+ def filter(self, predicate: Callable[[Any], bool]) -> 'Vector':
290
+ """Filter elements by predicate"""
291
+ result = Vector(self._element_type)
292
+ result.extend(item for item in self if predicate(item))
293
+ return result
294
+
295
+ def forEach(self, func: Callable[[Any], None]) -> 'Vector':
296
+ """Execute function for each element"""
297
+ for item in self:
298
+ func(item)
299
+ return self
300
+
301
+ def toArray(self) -> list:
302
+ """Convert to plain list"""
303
+ return list(self)
304
+
305
+ def fill(self, value: Any, start: int = 0, end: int = None) -> 'Vector':
306
+ """Fill range with value"""
307
+ if end is None:
308
+ end = len(self)
309
+ for i in range(start, min(end, len(self))):
310
+ self[i] = value
311
+ return self
312
+
313
+ def every(self, predicate: Callable[[Any], bool]) -> bool:
314
+ """Check if all elements match predicate"""
315
+ return all(predicate(item) for item in self)
316
+
317
+ def some(self, predicate: Callable[[Any], bool]) -> bool:
318
+ """Check if any element matches predicate"""
319
+ return any(predicate(item) for item in self)
320
+
321
+ def reduce(self, func: Callable[[Any, Any], Any], initial: Any = None) -> Any:
322
+ """Reduce vector to single value"""
323
+ from functools import reduce as py_reduce
324
+ if initial is None:
325
+ return py_reduce(func, self)
326
+ return py_reduce(func, self, initial)
327
+
328
+ def begin(self) -> int:
329
+ """Return iterator to beginning (C++ style)"""
330
+ return 0
331
+
332
+ def end(self) -> int:
333
+ """Return iterator to end (C++ style)"""
334
+ return len(self)
335
+
336
+
337
+ class Array(list):
338
+ """Array data structure with CSSL methods.
339
+
340
+ Standard array with push/pop/length operations.
341
+
342
+ Usage:
343
+ array<string> arr;
344
+ arr.push("Item");
345
+ arr.length(); # Returns 1
346
+ """
347
+
348
+ def __init__(self, element_type: str = 'dynamic'):
349
+ super().__init__()
350
+ self._element_type = element_type
351
+
352
+ def push(self, item: Any) -> 'Array':
353
+ """Add item to end"""
354
+ self.append(item)
355
+ return self
356
+
357
+ def push_back(self, item: Any) -> 'Array':
358
+ """Add item to end (alias for push)"""
359
+ self.append(item)
360
+ return self
361
+
362
+ def push_front(self, item: Any) -> 'Array':
363
+ """Add item to front"""
364
+ self.insert(0, item)
365
+ return self
366
+
367
+ def pop_back(self) -> Any:
368
+ """Remove and return last element"""
369
+ return self.pop() if self else None
370
+
371
+ def pop_front(self) -> Any:
372
+ """Remove and return first element"""
373
+ return self.pop(0) if self else None
374
+
375
+ def at(self, index: int) -> Any:
376
+ """Get item at index"""
377
+ if 0 <= index < len(self):
378
+ return self[index]
379
+ return None
380
+
381
+ def set(self, index: int, value: Any) -> 'Array':
382
+ """Set item at index"""
383
+ if 0 <= index < len(self):
384
+ self[index] = value
385
+ return self
386
+
387
+ def size(self) -> int:
388
+ """Return array size"""
389
+ return len(self)
390
+
391
+ def length(self) -> int:
392
+ """Return array length"""
393
+ return len(self)
394
+
395
+ def empty(self) -> bool:
396
+ """Check if array is empty"""
397
+ return len(self) == 0
398
+
399
+ def isEmpty(self) -> bool:
400
+ """Check if array is empty (camelCase alias)"""
401
+ return len(self) == 0
402
+
403
+ def first(self) -> Any:
404
+ """Get first element"""
405
+ return self[0] if self else None
406
+
407
+ def last(self) -> Any:
408
+ """Get last element"""
409
+ return self[-1] if self else None
410
+
411
+ def contains(self, item: Any) -> bool:
412
+ """Check if array contains item"""
413
+ return item in self
414
+
415
+ def indexOf(self, item: Any) -> int:
416
+ """Find index of item (-1 if not found)"""
417
+ try:
418
+ return self.index(item)
419
+ except ValueError:
420
+ return -1
421
+
422
+ def lastIndexOf(self, item: Any) -> int:
423
+ """Find last index of item (-1 if not found)"""
424
+ for i in range(len(self) - 1, -1, -1):
425
+ if self[i] == item:
426
+ return i
427
+ return -1
428
+
429
+ def find(self, predicate: Callable[[Any], bool]) -> Any:
430
+ """Find first item matching predicate"""
431
+ for item in self:
432
+ if callable(predicate) and predicate(item):
433
+ return item
434
+ elif item == predicate:
435
+ return item
436
+ return None
437
+
438
+ def findIndex(self, predicate: Callable[[Any], bool]) -> int:
439
+ """Find index of first item matching predicate"""
440
+ for i, item in enumerate(self):
441
+ if callable(predicate) and predicate(item):
442
+ return i
443
+ elif item == predicate:
444
+ return i
445
+ return -1
446
+
447
+ def slice(self, start: int, end: int = None) -> 'Array':
448
+ """Return slice of array"""
449
+ if end is None:
450
+ result = Array(self._element_type)
451
+ result.extend(self[start:])
452
+ else:
453
+ result = Array(self._element_type)
454
+ result.extend(self[start:end])
455
+ return result
456
+
457
+ def join(self, separator: str = ',') -> str:
458
+ """Join elements into string"""
459
+ return separator.join(str(item) for item in self)
460
+
461
+ def map(self, func: Callable[[Any], Any]) -> 'Array':
462
+ """Apply function to all elements"""
463
+ result = Array(self._element_type)
464
+ result.extend(func(item) for item in self)
465
+ return result
466
+
467
+ def filter(self, predicate: Callable[[Any], bool]) -> 'Array':
468
+ """Filter elements by predicate"""
469
+ result = Array(self._element_type)
470
+ result.extend(item for item in self if predicate(item))
471
+ return result
472
+
473
+ def forEach(self, func: Callable[[Any], None]) -> 'Array':
474
+ """Execute function for each element"""
475
+ for item in self:
476
+ func(item)
477
+ return self
478
+
479
+ def toArray(self) -> list:
480
+ """Convert to plain list"""
481
+ return list(self)
482
+
483
+ def fill(self, value: Any, start: int = 0, end: int = None) -> 'Array':
484
+ """Fill range with value"""
485
+ if end is None:
486
+ end = len(self)
487
+ for i in range(start, min(end, len(self))):
488
+ self[i] = value
489
+ return self
490
+
491
+ def every(self, predicate: Callable[[Any], bool]) -> bool:
492
+ """Check if all elements match predicate"""
493
+ return all(predicate(item) for item in self)
494
+
495
+ def some(self, predicate: Callable[[Any], bool]) -> bool:
496
+ """Check if any element matches predicate"""
497
+ return any(predicate(item) for item in self)
498
+
499
+ def reduce(self, func: Callable[[Any, Any], Any], initial: Any = None) -> Any:
500
+ """Reduce array to single value"""
501
+ from functools import reduce as py_reduce
502
+ if initial is None:
503
+ return py_reduce(func, self)
504
+ return py_reduce(func, self, initial)
505
+
506
+ def concat(self, *arrays) -> 'Array':
507
+ """Concatenate with other arrays"""
508
+ result = Array(self._element_type)
509
+ result.extend(self)
510
+ for arr in arrays:
511
+ result.extend(arr)
512
+ return result
513
+
514
+ def flat(self, depth: int = 1) -> 'Array':
515
+ """Flatten nested arrays"""
516
+ result = Array(self._element_type)
517
+ for item in self:
518
+ if isinstance(item, (list, Array)) and depth > 0:
519
+ if depth == 1:
520
+ result.extend(item)
521
+ else:
522
+ nested = Array(self._element_type)
523
+ nested.extend(item)
524
+ result.extend(nested.flat(depth - 1))
525
+ else:
526
+ result.append(item)
527
+ return result
528
+
529
+ def unique(self) -> 'Array':
530
+ """Return array with unique elements"""
531
+ result = Array(self._element_type)
532
+ seen = set()
533
+ for item in self:
534
+ key = item if isinstance(item, (int, str, float, bool)) else id(item)
535
+ if key not in seen:
536
+ seen.add(key)
537
+ result.append(item)
538
+ return result
539
+
540
+ def begin(self) -> int:
541
+ """Return iterator to beginning (C++ style)"""
542
+ return 0
543
+
544
+ def end(self) -> int:
545
+ """Return iterator to end (C++ style)"""
546
+ return len(self)
547
+
151
548
 
152
549
  class Shuffled(list):
153
550
  """Unorganized fast storage for multiple returns.
@@ -542,11 +939,15 @@ def create_parameter(args: List[Any] = None) -> Parameter:
542
939
  """Create a Parameter object for accessing exec arguments"""
543
940
  return Parameter(args)
544
941
 
942
+ def create_array(element_type: str = 'dynamic') -> Array:
943
+ """Create an Array object"""
944
+ return Array(element_type)
945
+
545
946
 
546
947
  __all__ = [
547
948
  'DataStruct', 'Shuffled', 'Iterator', 'Combo', 'DataSpace', 'OpenQuote',
548
- 'OpenFind', 'Parameter', 'Stack', 'Vector',
949
+ 'OpenFind', 'Parameter', 'Stack', 'Vector', 'Array',
549
950
  'create_datastruct', 'create_shuffled', 'create_iterator',
550
951
  'create_combo', 'create_dataspace', 'create_openquote', 'create_parameter',
551
- 'create_stack', 'create_vector'
952
+ 'create_stack', 'create_vector', 'create_array'
552
953
  ]