Easy to understand and use a trick.
Use Hash Table to store value, Using a int variable to track the default "global setAll". When call getValue, if the index# is not in the Hash Table, return the "global" int. And When call setAll, simplicity update the "global" int. Below it's my code in C#,hope it helps: