Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of date storage method of three-dimensional structure, memory storage, querying method and inquiry unit, for solving the low problem of efficiency data query in prior art.
For achieving the above object and other relevant objects, the invention provides a kind of date storage method of three-dimensional structure, the date storage method of described three-dimensional structure comprises the following steps: the Array for structural body providing fixed size, the subscript key assignments that correspondence is different respectively of described Array for structural body; The key assignments of every data to be stored is obtained by preset function; By data to be stored respectively corresponding stored in the Array for structural body that the key assignments with every data to be stored matches; For the data to be stored in described Array for structural body set gradually the floor height meeting default floor height scope.
The invention provides a kind of data storage device of three-dimensional structure, the data storage device of described three-dimensional structure comprises: provide module, for providing the Array for structural body of fixed size, and the subscript key assignments that correspondence is different respectively of described Array for structural body; Key assignments acquisition module, for obtaining the key assignments treating every data to be stored by preset function; Preserve module, for by data to be stored respectively corresponding stored in the Array for structural body that the key assignments with every data to be stored matches; Floor height arranges module, for setting gradually for the data to be stored in described Array for structural body the floor height meeting default floor height scope.
The invention provides a kind of data enquire method of three-dimensional structure, the data enquire method institute data query of described three-dimensional structure is stored by the date storage method of three-dimensional structure as the aforementioned and is formed; The data enquire method of described three-dimensional structure comprises the following steps: the key assignments being obtained data to be checked by preset function; Obtain the Array for structural body corresponding with the key assignments of described data to be checked; In the structured data group corresponding with the key assignments of described data to be checked, inquire about according to size of data from top; When the current data inquiring current layer is greater than data to be checked, before current data, a data node jumps in the lower adjacent layer of floor height and inquires about.
In one embodiment of the invention, described data enquire method also comprises: when all data inquiring current layer are all less than data to be checked, jumps in the lower adjacent layer of floor height inquire about from the maximum data node of current layer.
In one embodiment of the invention, when inquiring about in the adjacent layer that floor height is lower, inquire about to the direction that data are larger from the back end of redirect according to size of data.
In one embodiment of the invention, described data enquire method also comprises: when the current data inquiring current layer is identical with data to be checked, determines that current data is data to be checked.
The invention provides a kind of data query arrangement of three-dimensional structure, the data query arrangement of described three-dimensional structure comprises: key assignments acquisition module, for being obtained the key assignments of data to be checked by preset function; Structured data acquisition module, for obtaining the Array for structural body corresponding with the key assignments of described data to be checked; Data inquiry module, in the structured data group corresponding with the key assignments of described data to be checked, inquires about according to size of data from top; Floor height handover module, during for being greater than data to be checked in the current data inquiring current layer, before current data, a data node jumps in the lower adjacent layer of floor height and inquires about.
In one embodiment of the invention, when described floor height handover module is also for being all less than data to be checked in all data inquiring current layer, jumps in the lower adjacent layer of floor height from the maximum data node of current layer and inquiring about.
In one embodiment of the invention, when described data inquiry module also for inquiring about in the adjacent layer that floor height is lower, inquire about to the direction that data are larger from the back end of redirect according to size of data.
In one embodiment of the invention, described data inquiry module also for when the current data inquiring current layer is identical with data to be checked, determines that current data is data to be checked.
As mentioned above, the date storage method of three-dimensional structure of the present invention, memory storage, querying method and inquiry unit, have following beneficial effect:
In date storage method of the present invention, querying method, by obtaining unique key assignments of data, and the floor height of bits per inch certificate is set, thus achieves orderly data storage; Like this when data query, by the Array for structural body that key assignments inquiry is corresponding, and achieve the quick position of data according to floor height difference, achieved the fast query of data by such mode, substantially increase the efficiency of data query.
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this instructions can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this instructions also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.It should be noted that, when not conflicting, the feature in following examples and embodiment can combine mutually.
It should be noted that, the diagram provided in following examples only illustrates basic conception of the present invention in a schematic way, then only the assembly relevant with the present invention is shown in graphic but not component count, shape and size when implementing according to reality is drawn, it is actual when implementing, and the kenel of each assembly, quantity and ratio can be a kind of change arbitrarily, and its assembly layout kenel also may be more complicated.
As described in the background art, the data storage and management method used now is too loaded down with trivial details, complicated in the method realized, thus causes the search efficiency of data low.
And the present invention is by drawing some algorithm characteristics, shirtsleeve operation is carried out in the operation for data, realizes a kind of simple, understandable method, realize for data increasing, delete, change, look into work energy, thus reach the accurately process fast for data.
Refer to Fig. 1, the invention provides a kind of date storage method of three-dimensional structure, the date storage method of described three-dimensional structure comprises the following steps:
S11, provides the Array for structural body of fixed size, the subscript key assignments that correspondence is different respectively of described Array for structural body;
In a particular embodiment, the subscript (key assignments) of every Array for structural body is obtained by preset function;
S12, obtains the key assignments treating every data to be stored by preset function;
S13, by data to be stored respectively corresponding stored in the Array for structural body that the key assignments with every data to be stored matches;
S14, for the data to be stored in described Array for structural body set gradually the floor height meeting default floor height scope.
Be described in detail in conjunction with the storage means of embodiment to the present embodiment more below.
First the Array for structural body of fixed size is provided, such as can by Array for structural body the structure be set to shown in table 1, can certainly arrange according to the actual requirements, this should not limit the scope of the invention.
Table 1
The subscript of the Array for structural body shown in table 1 is the key assignments that we will be obtained by setting function.
The process of concrete acquisition key assignments is as follows: by setting a function, parameter is passed in function, carries out certain computing and obtains a unique key assignments.When design function, in order to access the overabundance of data after each node below preventing, obtaining key assignments function and preferably can realize being uniform distribution, avoiding like this occurring hanging up a large amount of data after some nodes, cause whole three-dimensional structure uneven.The function of setting can adopt existing function to realize, and does not repeat them here.
Because the data inserted inevitably there will be the identical data of key assignments, sequencedly be inserted into after current node to the operation of these data, produce an orderly chained list, and for each node be inserted in chained list produces a random floor height, but the floor height of current generation can not exceed the maximal value (the floor height upper limit that initial setting can be maximum) of floor height.
After being calculated parameter by setting function, the key assignments of acquisition must in the scope of array index.Here each Array for structural body member is a structure, and each member at least will comprise the pointer that is pointed to node below, after being convenient to produce key assignments, and data inserting after this node, also convenient index search backward.Such as:
Structname1{
Structname2*node;
intcurrent_level;
}arry[index];
The mode of adding data after each node is the sequential chained lists having height, can realize jump and search when making to search data again by such design.Wherein, currentlevel value record be in sequential chained list after this key assignments, floor height maximum in all chained list members, but this floor height value can not exceed the MAX_LEVEL (setting the restriction of maximum floor height in this method) of maximum restriction.
Again during data inserting, after finding the point that will insert, need generation random floor height, the random data of generation preferably meets and distributes just very much, and can increase search efficient, stable like this, function is realized by oneself definition.When the floor height produced is greater than current maximum floor height, but when being no more than the maximum floor height of setting, upgrade existing maximum floor height.In addition, when deleting, after finding data, if the data of deleting are current maximum floor heights, after deletion, upgrade current maximum floor height.
Date storage method of the present invention, by a kind of 3 D stereo implementation, is first according to data acquisition key assignments; Next is when follow-up data inserting, for current data produces a random height, realizes inquiry of jumping after convenient.Achieved the orderly storage of data by such storage mode, for follow-up inquiry is provided convenience, thus greatly improve the efficiency of inquiry.
With reference to figure 2, the invention provides a kind of data storage device of three-dimensional structure, the data storage device of described three-dimensional structure comprises: provide module 21, key assignments acquisition module 22, preservation module 23 and floor height to arrange module 24.
The described module 21 that provides is for providing the Array for structural body of fixed size, and the subscript of described Array for structural body distinguishes corresponding different key assignments;
Described key assignments acquisition module 22 is for obtaining the key assignments treating every data to be stored by preset function;
Described preservation module 23 for by data to be stored respectively corresponding stored in the Array for structural body that the key assignments with every data to be stored matches;
Described floor height arranges module 24 for setting gradually for the data to be stored in described Array for structural body the floor height meeting default floor height scope.
Implementation procedure and the aforesaid date storage method of the data storage device of the present embodiment are similar, do not repeat them here.
The present invention also provides a kind of data enquire method of three-dimensional structure, and the data enquire method institute data query of described three-dimensional structure is stored by the date storage method of aforesaid three-dimensional structure and formed; With reference to figure 3, the data enquire method of described three-dimensional structure comprises the following steps:
S31, obtains the key assignments of data to be checked by preset function;
S32, obtains the Array for structural body corresponding with the key assignments of described data to be checked;
S33, in the structured data group corresponding with the key assignments of described data to be checked, inquires about according to size of data from top;
S34, when the current data inquiring current layer is greater than data to be checked, before current data, a data node jumps in the lower adjacent layer of floor height and inquires about.
In the present embodiment, when all data inquiring current layer are all less than data to be checked, jump in the lower adjacent layer of floor height from the maximum data node of current layer and inquire about.
Particularly, when inquiring about in the adjacent layer that floor height is lower, inquire about to the direction that data are larger from the back end of redirect according to size of data.When the adjacent layer that floor height is lower is inquired about, the size of same judgement current data and data to be checked, when current data is greater than data to be checked, before current data, a data node jumps to the lower adjacent layer of floor height, continue to inquire about to the direction that data are larger, repeat above-mentioned query script until when the current data that inquires current layer is identical with data to be checked, determine that current data is data to be checked.
Below in conjunction with specific embodiment, above-mentioned data enquire method is described further.
With reference to figure 4, what show is the data obtaining identical key assignments (array index), the situation of the sequential chained list formed after node, the level record in this chained list be the height of the * forward [] of the variable data array of current data, both subscripts of * forward [].
After storage, the Major Members of node:
Structname2{
Void*data;
Structname2*forward[];
Intlevel;
}
Each node data storage method below as shown in Figure 4, searches data searching, until the data of looking for required for finding in layer from top downwards at every turn.Such as search 85, first have the maximal value (1) preset and a minimum value (-1), crossing the border to prevent from searching, being limited in this scope and searching.
Search and start to check from level3, once backward, when finding 37, judge larger than 37, less than 1, start from the node of 37 jump to lower one deck then from 37 backward compare, when finding level1 successively downwards, find 85 end.In the process of searching, because the type of data is indefinite, needs oneself design comparison function, compare the size of data inserting, produce an order chained list.
For another example, when we are in follow-up searching, if when will search data 32, we calculate a key assignments by the function of specifying, and go to search in the sequential chained list after can directly locking onto which node by this key assignments.After this chained list, start Fig. 4, go to search according to the mode of great-jump-forward, first start to be searched downwards by height from top (the top height this sequential chained list, this floor height value must be less than or equal to MAX_LEVEL (the maximum floor height of restriction)) of this node.When searching 32, in this figure, be three layers to the maximum, level3 relatively after 32 be greater than 21, be less than 37.Start to jump to level2 from 21 nodes, start backward to compare, find to be less than 37.Jumped downwards by the place of 21 data again, repeat, in the action of level2 layer, to compare backward, find the value equaling 32, then judge whether it is the value that will search.
The data enquire method of the present embodiment, first achieves the accurate location of data, then searches data at the follow-up great-jump-forward in process that relocates, more convenient and swift, promotes the execution efficiency of code.
With reference to figure 5, the present invention also provides a kind of data query arrangement of three-dimensional structure, and the data query arrangement of described three-dimensional structure comprises: key assignments acquisition module 41, structured data acquisition module 42, data inquiry module 43 and floor height handover module 44.
Described key assignments acquisition module 41 is for obtaining the key assignments of data to be checked by preset function; The key assignments acquisition module 41 of the present embodiment with reference to the key assignments acquisition module 22 in figure 2, can not repeat them here.
Described structured data acquisition module 42 is for obtaining the Array for structural body corresponding with the key assignments of described data to be checked;
Described data inquiry module 43, in the structured data group corresponding with the key assignments of described data to be checked, is inquired about according to size of data from top;
When described floor height handover module 44 is for being greater than data to be checked in the current data inquiring current layer, before current data, a data node jumps in the lower adjacent layer of floor height and inquires about.
In the present embodiment, when described floor height handover module 44 is also for being all less than data to be checked in all data inquiring current layer, jumps in the lower adjacent layer of floor height from the maximum data node of current layer and inquiring about.
When described data inquiry module 43 also for inquiring about in the adjacent layer that floor height is lower, inquire about to the direction that data are larger from the back end of redirect according to size of data.Repeat query script successively until when the current data inquiring current layer is identical with data to be checked, determine that current data is data to be checked.
The implementation procedure of the inquiry unit of the present embodiment with reference to the aforementioned detailed description about querying method, can not repeat them here.
In sum, the date storage method of three-dimensional structure of the present invention, memory storage, querying method and inquiry unit, implementation is simple, data manipulation accurately and fast; Not only achieve the accurate location of data, and searched by great-jump-forward, substantially increase the efficiency of data query.So the present invention effectively overcomes various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.