From bc6bf8c3b04fe074020b5de17f5b486bf61b2220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 17 Jan 2023 16:27:52 -0300 Subject: [PATCH 24/51] Mark non-modifying map functions as const --- wadsrc/static/zscript/engine/maps.zs | 110 +++++++++++++++------------ 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/wadsrc/static/zscript/engine/maps.zs b/wadsrc/static/zscript/engine/maps.zs index d10ffe5d1..20ef85ab4 100644 --- a/wadsrc/static/zscript/engine/maps.zs +++ b/wadsrc/static/zscript/engine/maps.zs @@ -5,11 +5,12 @@ struct Map_I32_I8 native native void Move(Map_I32_I8 other); native void Swap(Map_I32_I8 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native int Get(int key); - native bool CheckKey(int key); - native void Insert(int key,int value); + native bool CheckKey(int key) const; + + native void Insert(int key, int value); native void InsertNew(int key); native void Remove(int key); } @@ -33,10 +34,11 @@ struct Map_I32_I16 native native void Move(Map_I32_I16 other); native void Swap(Map_I32_I16 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native int Get(int key); - native bool CheckKey(int key); + native bool CheckKey(int key) const; + native void Insert(int key,int value); native void InsertNew(int key); native void Remove(int key); @@ -61,11 +63,12 @@ struct Map_I32_I32 native native void Move(Map_I32_I32 other); native void Swap(Map_I32_I32 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native int Get(int key); - native bool CheckKey(int key); - native void Insert(int key,int value); + native bool CheckKey(int key) const; + + native void Insert(int key, int value); native void InsertNew(int key); native void Remove(int key); } @@ -89,11 +92,12 @@ struct Map_I32_F32 native native void Move(Map_I32_F32 other); native void Swap(Map_I32_F32 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native double Get(int key); - native bool CheckKey(int key); - native void Insert(int key,double value); + native bool CheckKey(int key) const; + + native void Insert(int key, double value); native void InsertNew(int key); native void Remove(int key); } @@ -117,11 +121,12 @@ struct Map_I32_F64 native native void Move(Map_I32_F64 other); native void Swap(Map_I32_F64 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native double Get(int key); - native bool CheckKey(int key); - native void Insert(int key,double value); + native bool CheckKey(int key) const; + + native void Insert(int key, double value); native void InsertNew(int key); native void Remove(int key); } @@ -145,11 +150,12 @@ struct Map_I32_Obj native native void Move(Map_I32_Obj other); native void Swap(Map_I32_Obj other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native Object Get(int key); - native bool CheckKey(int key); - native void Insert(int key,Object value); + native bool CheckKey(int key) const; + + native void Insert(int key, Object value); native void InsertNew(int key); native void Remove(int key); } @@ -173,11 +179,12 @@ struct Map_I32_Ptr native native void Move(Map_I32_Ptr other); native void Swap(Map_I32_Ptr other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native voidptr Get(int key); - native bool CheckKey(int key); - native void Insert(int key,voidptr value); + native bool CheckKey(int key) const; + + native void Insert(int key, voidptr value); native void InsertNew(int key); native void Remove(int key); } @@ -198,11 +205,12 @@ struct Map_I32_Str native native void Move(Map_I32_Str other); native void Swap(Map_I32_Str other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native String Get(int key); - native bool CheckKey(int key); - native void Insert(int key,String value); + native bool CheckKey(int key) const; + + native void Insert(int key, String value); native void InsertNew(int key); native void Remove(int key); } @@ -228,11 +236,12 @@ struct Map_Str_I8 native native void Move(Map_Str_I8 other); native void Swap(Map_Str_I8 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native int Get(String key); - native bool CheckKey(String key); - native void Insert(String key,int value); + native bool CheckKey(String key) const; + + native void Insert(String key, int value); native void InsertNew(String key); native void Remove(String key); } @@ -256,11 +265,12 @@ struct Map_Str_I16 native native void Move(Map_Str_I16 other); native void Swap(Map_Str_I16 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native int Get(String key); - native bool CheckKey(String key); - native void Insert(String key,int value); + native bool CheckKey(String key) const; + + native void Insert(String key, int value); native void InsertNew(String key); native void Remove(String key); } @@ -284,11 +294,12 @@ struct Map_Str_I32 native native void Move(Map_Str_I32 other); native void Swap(Map_Str_I32 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native int Get(String key); - native bool CheckKey(String key); - native void Insert(String key,int value); + native bool CheckKey(String key) const; + + native void Insert(String key, int value); native void InsertNew(String key); native void Remove(String key); } @@ -312,11 +323,12 @@ struct Map_Str_F32 native native void Move(Map_Str_F32 other); native void Swap(Map_Str_F32 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native double Get(String key); - native bool CheckKey(String key); - native void Insert(String key,double value); + native bool CheckKey(String key) const; + + native void Insert(String key, double value); native void InsertNew(String key); native void Remove(String key); } @@ -340,11 +352,12 @@ struct Map_Str_F64 native native void Move(Map_Str_F64 other); native void Swap(Map_Str_F64 other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native double Get(String key); - native bool CheckKey(String key); - native void Insert(String key,double value); + native bool CheckKey(String key) const; + + native void Insert(String key, double value); native void InsertNew(String key); native void Remove(String key); } @@ -368,11 +381,12 @@ struct Map_Str_Obj native native void Move(Map_Str_Obj other); native void Swap(Map_Str_Obj other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native Object Get(String key); - native bool CheckKey(String key); - native void Insert(String key,Object value); + native bool CheckKey(String key) const; + + native void Insert(String key, Object value); native void InsertNew(String key); native void Remove(String key); } @@ -396,11 +410,12 @@ struct Map_Str_Ptr native native void Move(Map_Str_Ptr other); native void Swap(Map_Str_Ptr other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native voidptr Get(String key); - native bool CheckKey(String key); - native void Insert(String key,voidptr value); + native bool CheckKey(String key) const; + + native void Insert(String key, voidptr value); native void InsertNew(String key); native void Remove(String key); } @@ -424,11 +439,12 @@ struct Map_Str_Str native native void Move(Map_Str_Str other); native void Swap(Map_Str_Str other); native void Clear(); - native uint CountUsed(); + native uint CountUsed() const; native String Get(String key); - native bool CheckKey(String key); - native void Insert(String key,String value); + native bool CheckKey(String key) const; + + native void Insert(String key, String value); native void InsertNew(String key); native void Remove(String key); } -- 2.39.3