Last active
August 29, 2015 14:21
-
-
Save kaikuchn/de57ad11f532b079dace to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function find_or_create_node(dict As Dictionary, key As String) As Dictionary | |
If Not dict.Exists(key) | |
dict.Add(key, new Dictionary) | |
End If | |
Return dict.Item(key) | |
End Function | |
Sub initialize_or_increment_leaf(dict As Dictionary, key As String, value As Double) | |
If Not dict.Exists(key) | |
dict.Add(key, value) | |
Else | |
dict.Item(key) = dict.Item(key) + value | |
End If | |
End Sub | |
' Use like this | |
sub_projects_dict = find_or_create_node(projects_dict, project_id); | |
months_dict = find_or_create_node(sub_projects_dict, sub_project_id); | |
initialize_or_increment_leaf(months_dict, current_month, working_hours); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment