Not a thing to do with general-purpose data structures, but for the sake of the argument, yeah a getter free design would look something like that (though you could argue this is not exactly a hash table anymore). You would not encapsulate the action (by which I presume you mean make it entirely internal to the class) - as that's a very different design. Passing in an action is just dependency injection (it could also be an object) - you'd do this sort of thing if your class needs to call something, but cannot know what that something is. But again, not how hash tables are conceptualized.
↧