~eda-qa/leaflang/cpp

« back to all changes in this revision

Viewing changes to share/std_library/std/vector.leaf

  • Committer: edA-qa mort-ora-y
  • Date: 2017-08-19 06:03:00 UTC
  • mfrom: (100.1.22 misc)
  • Revision ID: eda-qa@disemia.com-20170819060300-209dwd5884343mi0
merging miscelaneous changes, mainly platform improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@export class vector「T」 {
 
2
        var size : integer
 
3
        var data : array「T」
 
4
        
 
5
        defn push = ( x : T ) -> {
 
6
                var s = size + 1
 
7
                do s > data.size ? {
 
8
                        expand(s*2)
 
9
                }
 
10
                
 
11
                data#size = x
 
12
                size = s
 
13
        }
 
14
        
 
15
        defn expand = ( s : integer ) -> {
 
16
                var d = type「array「T」」(s)
 
17
                for i in std.range(0,size) {
 
18
                        d#i = data#i
 
19
                }
 
20
                data = d
 
21
        }
 
22
}