This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
Generated
+21
@@ -0,0 +1,21 @@
|
||||
struct ScanBuffer:
|
||||
var samples: List[Int]
|
||||
|
||||
def __init__(out self, var samples: List[Int]):
|
||||
self.samples = samples^
|
||||
|
||||
def push(mut self, t: Int):
|
||||
self.samples.append(t)
|
||||
|
||||
def size(self) -> Int:
|
||||
return len(self.samples)
|
||||
|
||||
|
||||
def main():
|
||||
var original: List[Int] = [1, 2, 3]
|
||||
var snapshot = ScanBuffer(original^)
|
||||
# The black-box recorder keeps an independent copy so later edits don't leak in.
|
||||
var working = snapshot.copy()
|
||||
working.push(99)
|
||||
print("snapshot size:", snapshot.size())
|
||||
print("working size:", working.size())
|
||||
Reference in new issue
Block a user