2022-01-13 05:24:03 +01:00
|
|
|
function ds_list_create_from_array(array) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var l = ds_list_create();
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(array); i < n; i++ ) {
|
2022-01-13 05:24:03 +01:00
|
|
|
l[| i] = array[i];
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ds_list_to_array(list) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(!ds_exists(list, ds_type_list)) return [];
|
|
|
|
|
|
|
|
var a = array_create(ds_list_size(list));
|
2023-08-22 14:35:13 +02:00
|
|
|
for( var i = 0; i < ds_list_size(list); i++ )
|
2022-01-13 05:24:03 +01:00
|
|
|
a[i] = list[| i];
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
function ds_list_add_list(list, list_add) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
ds_list_add(list, list_add);
|
|
|
|
ds_list_mark_as_list(list, ds_list_size(list) - 1);
|
|
|
|
}
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
function ds_list_add_map(list, map) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
ds_list_add(list, map);
|
|
|
|
ds_list_mark_as_map(list, ds_list_size(list) - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ds_list_get(list, index, def = 0) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(index < ds_list_size(list)) return list[| index];
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
2022-09-27 06:37:28 +02:00
|
|
|
function ds_list_clone(list, mem = false) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var l = ds_list_create();
|
2022-09-27 06:37:28 +02:00
|
|
|
if(!ds_exists(list, ds_type_list)) return l;
|
|
|
|
|
|
|
|
if(mem) {
|
|
|
|
for( var i = 0; i < ds_list_size(list); i++ )
|
|
|
|
ds_list_add(l, list[| i]);
|
|
|
|
} else
|
|
|
|
ds_list_copy(l, list);
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ds_list_remove(list, item) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
var in = ds_list_find_index(list, item);
|
|
|
|
if(in >= 0) ds_list_delete(list, in);
|
2022-01-25 10:58:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function ds_list_append(list, _append) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2024-06-24 08:02:03 +02:00
|
|
|
for( var i = 0; i < ds_list_size(_append); i++ )
|
2022-01-25 10:58:11 +01:00
|
|
|
ds_list_add(list, _append[| i]);
|
2024-06-24 08:02:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function ds_list_append_array(list, _append) {
|
|
|
|
INLINE
|
|
|
|
|
|
|
|
for( var i = 0; i < array_length(_append); i++ )
|
|
|
|
ds_list_add(list, _append[i]);
|
2022-09-23 13:28:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function ds_list_exist(list, item) {
|
2024-03-31 05:36:11 +02:00
|
|
|
INLINE
|
|
|
|
|
2022-11-03 11:44:49 +01:00
|
|
|
return ds_list_find_index(list, item) >= 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|