function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
I have a text and it has merged fields. Instead of using direct string replace, is it possible to use hash table concept? How to do in apex code?
Thanks
The APEX implementation of a hash table is a Map. Example (untested):
Map<String,List<Account>> aMap = new Map<String,List<Account>>(); for(Account a : [SELECT Id,Name,BillingCity FROM Account LIMIT 200]) { if(aMap.containsKey(a.BillingCity)) { aMap.get(a.BillingCity).add(new List<Account>{a}); } else { aMap.put(a.BillingCity,new List<Account>{a}); } }
This populates a hashmap with all accounts per billingcity (billingcity being the hash key).
The APEX implementation of a hash table is a Map. Example (untested):
Map<String,List<Account>> aMap = new Map<String,List<Account>>(); for(Account a : [SELECT Id,Name,BillingCity FROM Account LIMIT 200]) { if(aMap.containsKey(a.BillingCity)) { aMap.get(a.BillingCity).add(new List<Account>{a}); } else { aMap.put(a.BillingCity,new List<Account>{a}); } }
This populates a hashmap with all accounts per billingcity (billingcity being the hash key).