@@ -38,28 +38,28 @@ bool ListBlocks::categoryVisible() const
3838Value ListBlocks::addToList (const BlockArgs &args)
3939{
4040 auto list = std::static_pointer_cast<List>(args.field (LIST)->valuePtr ());
41- list->append (args.input (ITEM)->value ());
41+ list->push_back (args.input (ITEM)->value ());
4242 return Value ();
4343}
4444
4545Value ListBlocks::deleteFromList (const BlockArgs &args)
4646{
4747 auto list = std::static_pointer_cast<List>(args.field (LIST)->valuePtr ());
4848 Value value = args.input (INDEX)->value ();
49- int index;
49+ size_t index;
5050 if (value.isString ()) {
5151 std::string str = value.toString ();
5252 if (str == " last" )
53- index = list->length ();
53+ index = list->size ();
5454 else if (str == " all" ) {
5555 list->clear ();
5656 return Value ();
5757 } else if (str == " random" ) {
58- index = list->length () == 0 ? 0 : randint (1 , list->length ());
58+ index = list->size () == 0 ? 0 : randint< size_t > (1 , list->size ());
5959 } else
6060 return Value ();
6161 } else
62- index = validateIndex (value.toInt (), list->length ());
62+ index = validateIndex (value.toInt (), list->size ());
6363 if (index == 0 )
6464 return Value ();
6565 list->removeAt (index - 1 );
@@ -81,14 +81,14 @@ Value ListBlocks::insertToList(const BlockArgs &args)
8181 if (value.isString ()) {
8282 std::string str = value.toString ();
8383 if (str == " last" ) {
84- list->append (args.input (ITEM)->value ());
84+ list->push_back (args.input (ITEM)->value ());
8585 return Value ();
8686 } else if (str == " random" ) {
87- index = list->length () == 0 ? 1 : randint (1 , list->length ());
87+ index = list->size () == 0 ? 1 : randint< size_t > (1 , list->size ());
8888 } else
8989 return Value ();
9090 } else {
91- index = validateIndex (value.toInt (), list->length ());
91+ index = validateIndex (value.toInt (), list->size ());
9292 if (index == 0 )
9393 return Value ();
9494 }
@@ -104,13 +104,13 @@ Value ListBlocks::replaceItemOfList(const BlockArgs &args)
104104 if (value.isString ()) {
105105 std::string str = value.toString ();
106106 if (str == " last" )
107- index = list->length ();
107+ index = list->size ();
108108 else if (str == " random" ) {
109- index = list->length () == 0 ? 0 : randint (1 , list->length ());
109+ index = list->size () == 0 ? 0 : randint< size_t > (1 , list->size ());
110110 } else
111111 return Value ();
112112 } else
113- index = validateIndex (value.toInt (), list->length ());
113+ index = validateIndex (value.toInt (), list->size ());
114114 if (index == 0 )
115115 return Value ();
116116 list->replace (index - 1 , args.input (ITEM)->value ());
@@ -125,13 +125,13 @@ Value ListBlocks::itemOfList(const BlockArgs &args)
125125 if (value.isString ()) {
126126 std::string str = value.toString ();
127127 if (str == " last" )
128- index = list->length ();
128+ index = list->size ();
129129 else if (str == " random" ) {
130- index = list->length () == 0 ? 0 : randint (1 , list->length ());
130+ index = list->size () == 0 ? 0 : randint< size_t > (1 , list->size ());
131131 } else
132132 return " " ;
133133 } else
134- index = validateIndex (value.toInt (), list->length ());
134+ index = validateIndex (value.toInt (), list->size ());
135135 if (index == 0 )
136136 return " " ;
137137 return list->at (index - 1 );
@@ -146,7 +146,7 @@ Value ListBlocks::itemNumberInList(const BlockArgs &args)
146146Value ListBlocks::lengthOfList (const BlockArgs &args)
147147{
148148 auto list = std::static_pointer_cast<List>(args.field (LIST)->valuePtr ());
149- return list->length ();
149+ return list->size ();
150150}
151151
152152Value ListBlocks::listContainsItem (const BlockArgs &args)
@@ -155,7 +155,7 @@ Value ListBlocks::listContainsItem(const BlockArgs &args)
155155 return list->contains (args.input (ITEM)->value ());
156156}
157157
158- int ListBlocks::validateIndex (int index, int listLength)
158+ int ListBlocks::validateIndex (size_t index, size_t listLength)
159159{
160160 if (listLength == 0 ) {
161161 if (index != 1 )
0 commit comments