From: Christian Szegedy Date: 2002-09-20T01:20:46+09:00 Subject: Re: subclassing Integer John Tromp wrote: > I'm writing a state space search program where each state can be consisely > described by an Integer. I need these states to have several new methods. > > I can either > 1) create a new class with an Integer attribute > or > 2) try to subclass Integer > or > 3) pass around Integers to methods of another class > .... Snip ... > The only reason I would try option 2) is that > I expect to have 100s of millions of these States around, > and like 3) it might save memory. > > Does anyone know if option 1) will take more memory than option 3) > and if anything like option 2) can combine their advantages? > 1 or 2 would be equally inefficient (if 2 worked). 3) takes much less memory than any subclassing or a new structure. One efficient solution is to define new methods under the Integer class, but of course it is a bit nasty. Best Regards, Christian