モド vh_stdvecを作成
New vh_stdvec
 
Set v = New vh_stdvec
の時ジテン点ですべての機キノウが使シヨウ用可カノウ
Variantの1次元配列をmoveして自身のデータとする(LBound = 0にする)
Function from(ByRef v As Variant) As Variant
 
(from メソッドを発ハッコウ行すると以イゼンアタイ消える)
m = iota(1, 10)
Set v = New vh_stdvec
v.from m                             ← move なので配列ハイレツのサイズにカカわりなく作成サクセイできる
v.printS
[Data]: 0 -> 9 : [Accessible]: 0 -> 9
v.printM
  1  2  3  4  5  6  7  8  9  10      ← m のデータをウバ
printM m
                                             ← move されて Empty になっている
※ size、capacity ともにUbound(v)になる
モド 全ての要素を削除
Function clear() As vh_stdvec
 
v.clear
v.printS
[Data]: 0 -> -1 : [Accessible]: 0 -> -1
v.printM
#Empty Vector#
※ size、capacity ともに0になる
vh_stdvecどうしのswap
Function swap(ByVal target As vh_stdvec) As vh_stdvec
 
v1.from(iota(1, 10)).printM
  1  2  3  4  5  6  7  8  9  10
v2.from(array(5, 4, 3, 2, 1)).printM
  5  4  3  2  1
モド v1.swap v2                         '← える
v1.printM
  5  4  3  2  1
v2.printM
  1  2  3  4  5  6  7  8  9  10
同じ配列を持ったvh_stdvecオブジェクトの生成
Function clone() As vh_stdvec
 
v1.from(iota(1, 10)).printM
  1  2  3  4  5  6  7  8  9  10
Set v2 = v1.clone
v2.printM
モド   1  2  3  4  5  6  7  8  9  10
配列部分を戻して自身は解放(shrinkしてから出力シュツリョクする)
Function free() As Variant
 
x = v.free                               ← move なので代入ダイニュウ時間ジカン一瞬イッシュン
printM x
  1  2  3  4  5  6  7  8  9  10      ← v のデータをウバ
v.printS
[Data]: 0 -> -1 : [Accessible]: 0 -> -1
v.printM
モド #Empty Vector#
※ size、capacity ともに0になる
書き込み済み要素数を取得
Property Get size() As Long
 
v.printM
  1  2  3  4  5  6  7  8  9  10
?v.size
10
ReDimせずに格納できる最大の要素数を取得
Property Get capacity() As Long
 
?v.capacity
10                                モトのキャパシティ
v.push_back 11                 末尾マツビ要素ヨウソ追加ツイカしてみる
?v.capacity
20                                ←拡カクチョウ張された
v.push_back 12                 再度サイド追加ツイカ
?v.capacity
20                                ←拡カクチョウ不要フヨウでした
モド 領域を指定の長さまたはsizeまで切り詰める
Function shrink(Optional ByRef size_ As Variant) As vh_stdvec
 
?v.size
12
?v.capacity
20
?v.shrink.capacity
12                                ← shrink を引数ヒキスウなしですと capacity = size になる
?v.shrink(8).capacity
8                                 指定シテイしたナガさまでめる
v.printM
  1  2  3  4  5  6  7  8
指定した位置から個数を指定して範囲を削除する
Function erase_n(ByVal begin As Long, ByVal n As Long) As vh_stdvec
 
v.printM
  1  2  3  4  5  6  7  8  9  10
v.erase_n 4, 3
v.printM
  1  2  3  4  8  9  10              ← [5, 6, 7]が削除サクジョされた
※ capacity をえるナガさにしてもエラーにはならない
※ capacityは変化ヘンカしない
モド デバッグウィンドウに領域リョウイキ配列ハイレツ領域リョウイキを表示する
Sub printS()
 
v.printS
[Data]: 0 -> 6 : [Accessible]: 0 -> 9
デバッグウィンドウに 書き込み済み領域の全体または一部イチブを表示する
Sub printM(Optional ByRef r As Variant)
 
v.from(iota(1, 10)).printM
  1  2  3  4  5  6  7  8  9  10
デバッグウィンドウにジャグ配列を展開して表示する
Sub printM_(Optional ByRef r As Variant, Optional ByRef c As Variant)
 
Set v = New vh_stdvec
v.push_back iota(1,4)
v.push_back iota(11,14)
v.push_back iota(21,26)
v.push_back iota(0,9)
v.printM_
  1  2  3  4
  11  12  13  14
  21  22  23  24  25  26
  0  1  2  3  4  5  6  7  8  9
モド 指定位置の 値 を取得する(1以上の第2引数を指定した場合はその長さブン配列でカエす)
Property Get val(ByVal begin As Long, Optional ByVal len_ As Long = 0) As Variant
 
v.from  iota(1, 10) 
? v.val(3)
4
printM  v.val(3, 3)
  4  5  6
指定位置の 値 を取得する move版(1以上の第2引数を指定した場合はその長さ分配列で返す)
Property Get pop(ByVal begin As Long, Optional ByVal len_ As Long = 0) As Variant
 
v.from  iota(1, 10) 
? v.pop(3)
4
v.printM
  1  2  3    5  6  7  8  9  10
指定位置に値を設定する(値はmoveされる)
Function push(ByVal pos As Long, ByVal x As Variant) As vh_stdvec
 
v.printM
  1  2  3     5  6  7  8  9  10
v.push(3, 4).printM
  1  2  3  4  5  6  7  8  9  10
※ capacity 以上イジョウ位置イチへの設定セッテイはエラーとなる
※ エンド位置イチえる位置イチ設定セッテイをした場合バアイ、エンド位置イチはそこに移動イドウする
モド 同一の値に対する push の複数回適用
Function push_n(ByVal pos As Long, ByRef x As Variant, ByVal n As Long) As vh_stdvec
 
v.printM
  1  2  3  4  5  6  7  8  9  10
v.push_n(3, 111, 4).printM
  1  2  3  111  111  111  111  8  9  10
※ capacity 以上イジョウ位置イチへの設定セッテイはエラーとなる
※ エンド位置イチえる位置イチ設定セッテイをした場合バアイ、エンド位置イチはそこに移動イドウする
配列の一括 push
Function push_array(ByVal pos As Long, ByVal x As Variant) As vh_stdvec
 
v.printM
  1  2  3  4  5  6  7  8  9  10
v.push_array(3, iota(100, 104)).printM
  1  2  3  100  101  102  103  104  9  10
※ capacity 以上イジョウ位置イチへの設定セッテイはエラーとなる
※ エンド位置イチえる位置イチ設定セッテイをした場合バアイ、エンド位置イチはそこに移動イドウする
beginの位置の前にn個のEmptyを挿入する
Function insert_empty(ByVal begin As Long, ByVal n As Long) As vh_stdvec
 
v.from iota(1, 10)
モド v.printM
  1  2  3  4  5  6  7  8  9  10
v.insert_empty(4, 5).printM
  1  2  3  4            5  6  7  8  9  10
v.push_array(4, iota(101,105)).printM
  1  2  3  4  101  102  103  104  105  5  6  7  8  9  10
 
※ 挿入ソウニュウ開始カイシ位置イチbeginは0以上イジョウであればcapacityをえていてもよい
v.printM
  1  2  3  4  5  6  7  8  9  10
v.insert_empty(12, 5).printS
[Data]: 0 -> 9 : [Accessible]: 0 -> 19
書き込み済み末尾に対するpush(領域拡張する)
Function push_back(ByVal x As Variant) As vh_stdvec
 
v.clear
v.push_back(110).push_back(119).printM
  110  119
書き込み済み末尾に対する同一値の複数push(領域拡張する)
Function push_back_n(ByRef x As Variant, ByVal n As Long) As vh_stdvec
 
v.printM
  110  119
v.push_back_n("0120", 8).printM
モド   110  119  0120  0120  0120  0120  0120  0120  0120  0120
書き込み済み末尾に対するpush_array(領域拡張する)
Function push_back_array(ByVal arr As Variant) As vh_stdvec
 
v.printM
  110  119
a = iota(120, 127)
v.push_back_array(a).printM
  110  119  120  121  122  123  124  125  126  127
push_back_arrayの反復
Function push_back_arrays(ByVal arr As Variant) As vh_stdvec
 
a=iota(1,10)
b = iota(10, 20)
c = zipWith(p_a__o, a, b)
v.push_back_arrays(c).printM
  1  2  3  4  5  6  7  8  9  2  3  4  5  6  7  8  9  10  3  4  5  6  7  8  9  10  11
   4  5  6  7  8  9  10  11  12  5  6  7  8  9  10  11  12  13  6  7  8  9  10  11  12  13  14
   7  8  9  10  11  12  13  14  15  8  9  10  11  12  13  14  15  16  9  10  11  12  13  14 
   15  16  17  10  11  12  13  14  15  16  17  18
抽出条件を与えて配列をフィルタリングする
Function filter(ByRef pred As Variant) As vh_stdvec
 
モド v.from(iota(1, 20)).printM
  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20
v.filter(p_mod( ,2)).printM
  1  3  5  7  9  11  13  15  17  19
変換式を与えて配列を変換する
Function map(ByRef fun As Variant) As vh_stdvec
 
v.from(iota(1, 10)).printM
  1  2  3  4  5  6  7  8  9  10
v.map(p_mult).printM
  1  4  9  16  25  36  49  64  81  100
比較関数を与えて配列をソートする
Function orderby(ByRef comp As Variant) As vh_stdvec
 
v.from(uniform_int_dist(10, 1, 10)).printM
  7  1  6  3  9  10  9  6  4  4
v.orderby(p_less).printM
  1  3  4  4  6  6  7  9  9  10
 
v.from(uniform_int_dist(20, 1, 100)).printM
  33  36  64  55  100  49  47  92  30  49  25  65  90  40  31  35  68  34  45  41
モド v.filter(p_mod( ,2)).map(p_plus(100)).orderby(p_less).printM
  125  131  133  135  141  145  147  149  149  155  165