Skip to content

Commit

Permalink
+ More extended examples added.
Browse files Browse the repository at this point in the history
Signed-off-by: iconstudio <yoyofa2@hotmail.com>
  • Loading branch information
iconstudio committed Sep 13, 2020
1 parent 18e6320 commit c1db9ce
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 36 deletions.
86 changes: 50 additions & 36 deletions src/objects/oExample/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
draw_set_color($ffffff)
draw_set_halign(1)
draw_set_valign(1)
randomize()

///@function print(container)
function print(Cont) { foreach(Cont.first(), Cont.last(), show_debug_message) }

test1 = new List(4, 2, 8, 13, 11, 9) // 6
test2 = new Array(3, 3.5, 26, 7, 10, 15, 5, 4.5) // 8

test_sum = new List()
show_debug_message("\nThe First List")
sort(test1.first(), test1.last())
Expand Down Expand Up @@ -39,45 +41,12 @@ print(test_sum)
show_debug_message("Is parted: " + string(is_parted))
show_debug_message("Parted on: " + string(part_point.get_index()))

test_mapped_list = new Array("D", "E", "A", "T", "H", "K", "N", "I", "G", "H", "T")
// Transform into paired-container
transform(test_mapped_list.first(), test_mapped_list.last(), test_mapped_list.first(), function (Value) {
return [Value, irandom(3)]
})

show_debug_message("\nMap")
test_map = new Map(test_mapped_list)
print(test_map)
show_debug_message("Cashes of Map: ")
print(test_map.cash)

show_debug_message("\nUnordered_Map")
test_unomap = new Unordered_Map(test_mapped_list)
print(test_unomap)

/*
show_debug_message("\nMultimap")
show_debug_message("\nTransform a List into a Multimap")
// Transform into paired-container
transform(test_sum.first(), test_sum.last(), test_sum.first(), function (Value) {
return [irandom(2), Value]
})
test_multimap = new Multimap(test_sum)
for (var KIt = test_multimap.first(); KIt != test_multimap.last(); KIt.go()) {
var TempKey = test_multimap.get_key(KIt)
var TempList = test_multimap.get(KIt)
show_debug_message("Values with key " + string(TempKey) + ": ")
print(TempList)
}
/*
var nth = 10
var nth = 8
show_debug_message("\nNth Sorting (" + string(nth) + ")")
random_shuffle(test_sum.first(), test_sum.last())
var nth_interator = iterator_advance(test_sum.first(), nth)
var nth_value = nth_interator.get()
var nth_result = nth_element(test_sum.first(), nth_interator, test_sum.last())
nth_element(test_sum.first(), nth_interator, test_sum.last())
show_debug_message("Rearranged On: " + string(nth_interator.get_index()))
show_debug_message("The Stand Value: " + string(nth_value))

Expand All @@ -87,5 +56,50 @@ show_debug_message("The " + string(nth) + "th Iterator: " + string(nth_result_it
show_debug_message("The " + string(nth) + "th Value: " + string(nth_result_value))
print(test_sum)

show_debug_message("\nTransform a List into a paired List")
test_mapped_list = new List("D", "E", "A", "T", "H", "K", "N", "I", "G", "H", "T")
// Transform into paired-container
transform(test_mapped_list.first(), test_mapped_list.last(), test_mapped_list.first(), function (Value) {
return [Value, irandom(3)]
})
test_mapped_list.push_back(["@", "1st"])
test_mapped_list.push_back(["@", "2nd"])
test_mapped_list.push_back(["@", "3rd"])
test_mapped_list.push_back(["@", "4th"])
test_mapped_list.push_back(["@", "5th"])
test_mapped_list.push_back(["AA", "AA"])
test_mapped_list.push_back(["AB", "AB"])
test_mapped_list.push_back(["CT", "CT"])
test_mapped_list.push_back(["CZ", "CZ"])
test_mapped_list.push_back(["AC", "AC"]) // 17
show_debug_message("Map")
test_map = new Map(test_mapped_list)
print(test_map)

show_debug_message("\nUnordered_Map")
test_unomap = new Unordered_Map(test_mapped_list)
print(test_unomap)

show_debug_message("\nMultimap")
test_multimap = new Multimap(test_mapped_list)
test_multimap.insert(1, 10)
test_multimap.insert(2, 15)
test_multimap.insert(10, 50)
test_multimap.insert(11, 55)
test_multimap.insert(12, 60)
test_multimap.insert(0, new Wrapper("0-1st"))
test_multimap.insert(0, new Wrapper("0-2nd"))
test_multimap.insert(0, new Wrapper("0-3rd"))
test_multimap.insert(1, new Wrapper("1-1st"))
test_multimap.insert(1, new Wrapper("1-2nd"))
test_multimap.insert(1, new Wrapper("1-3rd"))

var i, TempPair, Key, Value
for (i = 0; i < test_multimap.bucket_count(); ++i) {
TempPair = test_multimap.at(i)
Key = TempPair[0]
Value = TempPair[1] // List
show_debug_message("Values with key " + string(Key) + ": ")
print(Value)
}

2 changes: 2 additions & 0 deletions src/objects/oExample/oExample.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c1db9ce

Please sign in to comment.