read write opertion with O(1) time complexity