History

reverse feature and unit test + example

Andrew Aday committed 3 years ago

Commit e7ef3c81 parent 7686e906 files · +122 −0Browse files

Showing the changes to src/core/chuck_lang.cpp (1 of 6 files). Show all

Unified · Split

src/core/chuck_lang.cpp+12−0
@@ -970,6 +970,11 @@ t_CKBOOL init_class_array( Chuck_Env * env, Chuck_Type * type ) · 969 unmodified lines
970970 func->add_arg( "string[]", "keys" );
971971 func->doc = "return all keys found in associative array in keys";
972972 if( !type_engine_import_mfun( env, func ) ) goto error;
973+
974+ // (1.4.2.1 azaday) add reverse()
975+ func = make_new_mfun( "void", "reverse", array_reverse );
976+ func->doc = "reverses the array in-place";
977+ if( !type_engine_import_mfun( env, func ) ) goto error;
973978
974979 // note 1.4.1.0: in the future, should deprecate and encourage programmer
975980 // to explicitly use .size() OR .capacity(), depending on the context
@@ -2782,6 +2787,13 @@ CK_DLL_MFUN( array_get_keys ) · 1806 unmodified lines
27822787 }
27832788 }
27842789
2790+// 1.4.2.1 azaday (added) array.reverse()
2791+CK_DLL_MFUN( array_reverse )
2792+{
2793+ Chuck_Array * array = (Chuck_Array *)SELF;
2794+ array->reverse();
2795+}
2796+
27852797
27862798
27872799 //-----------------------------------------------------------------------------

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t