The name of the template for a flexible data structure?

I am trying to understand a naming convention that accurately conveys what happens in the class that I am developing. On a secondary note, I'm trying to decide between two almost equivalent user APIs.

Here's the situation:

I am creating a scientific application where one of the central data structures has three phases: 1) accumulation, 2) analysis and 3) query execution.

In my case, this is a spatial modeling framework that internally uses KDTree to split a collection of points in three-dimensional space. Each point describes one or more attributes of the environment with a certain degree of confidence in the measurement itself.

After adding (potentially a large number of) measurements to the collection, the owner of the object will request it to obtain an interpolated measurement at a new data point somewhere in the corresponding field.

The API will look something like this (the code is in Java, but this is not very important, the code is divided into three sections for clarity):

// SECTION 1:
// Create the aggregation object, and get the zillion objects to insert...
ContinuousScalarField field = new ContinuousScalarField();
Collection<Measurement> measurements = getMeasurementsFromSomewhere();

// SECTION 2:
// Add all of the zillion objects to the aggregation object...
// Each measurement contains its xyz location, the quantity being measured,
// and a numeric value for the measurement. For example, something like
// "68 degrees F, plus or minus 0.5, at point 1.23, 2.34, 3.45"
foreach (Measurement m : measurements) {
   field.add(m);
}

// SECTION 3:
// Now the user wants to ask the model questions about the interpolated
// state of the model. For example, "what the interpolated temperature
// at point (3, 4, 5)
Point3d p = new Point3d(3, 4, 5);
Measurement result = field.interpolateAt(p);

In my specific problem domain during SECTION 2, you can perform a small number of additional operations (splitting points into balanced KDTree).

And there will be a little work (doing some linear interpolations) that may occur during SECTION 3.

( Fast Gauss , ), 2 3.

( interpolateAt), , "field.add()", .

, object.flip(), "append mode" " ". , , , . API . , ; .

, , ​​ ?

, , , ? , append ?

? , ?


ON EDIT:

, , "ContinuousScalarField".

, , :

, ( , ). , , - 10 .

, , , , .

, , .

, , 100%, .

: HashMap TreeMap . .

, , . HashMap , . TreeMap , - .

, , , , .

+3
6

, . , , . , , ..? ?

, , Builder Pattern . , , . void flip() Interpolator interpolator(), . interpolateAt Interpolator.

, , , , .

- . , Measurement Point, , , , Interpolator , .


, , , . :

Key[] data = new Key[...];
data[idx++] = new Key(...); /* Fast! */
...
Arrays.sort(data); /* Slow! */
...
boolean contains = Arrays.binarySearch(data, datum) >= 0; /* Fast! */

, , Set ( - ).

. . , , , .

- - (, ). , .

"" ( ) . , , factory. , .

+2

, , . , , IAppendable. , IAppendable, AsQueryable. , IQueryable.AsAppendable.

IAppendable IQueryable , , , () .

+4

. ContinuousScalarField ?

, - :

IInterpolator interpolator = field.GetInterpolator();
Measurement measurement = Interpolator.InterpolateAt(...);

, , .

+2

" " -

", " field.add() ", ". -

" , " - , , .

eval , . , .

: (a) ( ) () .

, . , ? , ?

, ( ) flip . , - - .

, , .

public void interpolateAt( Point3d p );
public Measurement interpolatedMasurement();

Open and Fetch . , . . . , . RDBMS .

+1

, , ? , append ?

, " " , , " " .

, "interpolate_at()" , , 3 "" . ( KDTree).

, - - .

, , - , - . , , - , , .

"-" , , "do_calculations()" , interpolateAt() , , interpolateAt() , , "do_calculations()" , , , .

, ​​ , "" "" "" " ". () StringBuilder StringBuffer () .

, , , , , . , , "add_data()" () interpolateAt().

"_", , , - . , , - "_", do_calculations() . , , , , . , "" , "" .

, , , . - , , . ( , , , "clear_cache()" "do_calculations()" ).

0

. , , STATE SECTION-1. SECTION-2, SECTION-3, . , , SECTION-3. , .

, : , . , , , .

-1

Source: https://habr.com/ru/post/1698884/


All Articles