java - How can I best make a class hold something for another class? -


I am facing some strange situations that, in some sense, are double to each other, and wondering if Someone has

external initialization
  class human {collection   

This is strange because humans (in this situation) never have their neighbors After they are not set they change (they are effectively written once), but this setup can not be done in the human constructor because people who fall in the next neighboring countries are required , When all humans are made Yes P>

Holding for someone else

Suppose I want to be able to store man in a tree-based map, to do this, to human A comparative identification card must be kept, even if it is not logically significant for the concept of human. Human creates this ID, but it is never used. Only the map uses it (or even should use it.)

In the first case, perhaps the disorder is a sign that neighboring should not have human property. Perhaps the Neighborhood object should be human property, and there is a method like humans. GetNeighbbs () can be used when real-time neighbors are required. Then a neighboring property for getNeighs gets a personal performance problem () method.

In the second case, how is its tree-based map providing a structure, then human is inherently unstructurable? If ID is irrelevant to human, then what is the map for it? Generally an ID is relevant, and the class is done by making sure that it is a specific identity, but if it is not really necessary, then you will see a different class, like a HumanKey map For humans, can use to rap.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -