CN117827845A - Node state updating method and device of tree structure and related medium - Google Patents

Node state updating method and device of tree structure and related medium Download PDF

Info

Publication number
CN117827845A
CN117827845A CN202410030758.3A CN202410030758A CN117827845A CN 117827845 A CN117827845 A CN 117827845A CN 202410030758 A CN202410030758 A CN 202410030758A CN 117827845 A CN117827845 A CN 117827845A
Authority
CN
China
Prior art keywords
node
updating
state
temporary variable
tree structure
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410030758.3A
Other languages
Chinese (zh)
Inventor
林浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Ruan Niu Technology Group Co ltd
Original Assignee
Shenzhen Ruan Niu Technology Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Ruan Niu Technology Group Co ltd filed Critical Shenzhen Ruan Niu Technology Group Co ltd
Priority to CN202410030758.3A priority Critical patent/CN117827845A/en
Publication of CN117827845A publication Critical patent/CN117827845A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a node state updating method, a node state updating device and a storage medium of a tree structure, wherein the method comprises the following steps: creating a tree structure of the dataset; the tree structure comprises nodes corresponding to each level of files of the data set; responding to node checking operation of a user on the tree structure, and determining a corresponding target node and child nodes and/or father nodes of the target node; based on node checking operation of a user, updating the current checking state of the target node by using a main thread, and updating the child nodes step by step and/or updating the father nodes step by step upwards by using a plurality of child threads according to the updated checking state. When the method and the device aim at the checking operation about the tree structure, the quick response of the checking operation for the tree structure can be realized by checking and updating the child nodes downwards and checking and updating the father nodes upwards.

Description

Node state updating method and device of tree structure and related medium
Technical Field
The present invention relates to the field of computer software technologies, and in particular, to a method and apparatus for updating node states of a tree structure, and a related medium.
Background
In some current software and operating systems, there is a disadvantage in using a tree structure to display a large data set (such as a file system), that is, the user cannot perform the checking operation because the checking operation is not supported or the speed of responding to the checking operation is not fast, or there is a delay between the operation of clicking the checking/canceling the checking operation by the user and the updating of the interface, which results in poor experience. For example, in some current tree-structured dataset presentation software, the difficulty of implementing the software and the stability of the software are often reduced by not adding a hook button, or the hook button is added, but since the interface update of the software must be executed in the main thread, after the user clicks the hook button, a developer usually updates the node state and refreshes the user interface in the main thread in a recursive manner. At this time, if the data aggregate is large, the depth of the node (i.e., the total number of nodes passed by the unique path from the root node to the node) is deep and the height of the node (i.e., the total number of nodes passed by the path from the current node to the farthest leaf node) is high, the user's hooking operation cannot get a timely response, and even causes a serious stuck unresponsiveness of the program. Therefore, how to implement a fast response to tree-structure checkpointing operations is a problem that needs to be solved by those skilled in the art.
Disclosure of Invention
The embodiment of the invention provides a node state updating method, device, computer equipment and storage medium of a tree structure, and aims to realize quick response to tree structure checking operation.
In a first aspect, an embodiment of the present invention provides a node status updating method of a tree structure, including:
creating a tree structure of the dataset; the tree structure comprises nodes corresponding to each level of files of the data set;
responding to node checking operation of a user on the tree structure, and determining a corresponding target node and child nodes and/or father nodes of the target node;
based on node checking operation of a user, updating the current checking state of the target node by using a main thread, and updating the child nodes step by step and/or updating the father nodes step by step upwards by using a plurality of child threads according to the updated checking state.
In a second aspect, an embodiment of the present invention provides a node status updating apparatus of a tree structure, including:
a structure creation unit for creating a tree structure of the data set; the tree structure comprises nodes corresponding to each level of files of the data set;
an operation response unit, configured to determine a corresponding target node and a child node and/or a parent node of the target node in response to a node hooking operation of a user on the tree structure;
and the node updating unit is used for updating the current checking state of the target node by utilizing the main thread based on the node checking operation of the user, and updating the child nodes step by step and/or updating the father nodes step by step upwards by utilizing a plurality of child threads according to the updated checking state.
In a third aspect, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the method for updating a node state of a tree structure according to the first aspect when the processor executes the computer program.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, where a computer program is stored, the computer program implementing the node state updating method of the tree structure according to the first aspect when executed by a processor.
The embodiment of the invention provides a node state updating method and device of a tree structure, computer equipment and a storage medium, wherein the method comprises the following steps: creating a tree structure of the dataset; the tree structure comprises nodes corresponding to each level of files of the data set; responding to node checking operation of a user on the tree structure, and determining a corresponding target node and child nodes and/or father nodes of the target node; based on node checking operation of a user, updating the current checking state of the target node by using a main thread, and updating the child nodes step by step and/or updating the father nodes step by step upwards by using a plurality of child threads according to the updated checking state. When the method and the device are used for checking the tree structure, the quick response of the checking operation of the tree structure can be realized by checking and updating the child nodes downwards and checking and updating the parent nodes upwards.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a node status updating method of a tree structure according to an embodiment of the present invention;
fig. 2 is a schematic sub-flowchart of step S103 in a node status updating method of a tree structure according to an embodiment of the present invention;
fig. 3 is a schematic sub-flowchart of step S203 in a node status updating method of a tree structure according to an embodiment of the present invention;
fig. 4 is another schematic sub-flowchart of step S203 in a node status updating method of a tree structure according to an embodiment of the present invention;
fig. 5 is an exemplary diagram of a node status updating method of a tree structure according to an embodiment of the present invention;
FIG. 6 is a schematic block diagram of a node status updating device with a tree structure according to an embodiment of the present invention;
FIG. 7 is a schematic block diagram of a node update unit in a tree-structured node status update apparatus according to an embodiment of the present invention;
FIG. 8 is a schematic block diagram of a parent-child update unit in a node status update apparatus with a tree structure according to an embodiment of the present invention;
fig. 9 is another sub-schematic block diagram of a parent-child update unit in a node status update apparatus with a tree structure according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, fig. 1 is a flow chart of a node status updating method of a tree structure according to an embodiment of the present invention, which specifically includes: steps S101 to S103.
S101, creating a tree structure of a data set; the tree structure comprises nodes corresponding to each level of files of the data set;
s102, responding to node choosing operation of the tree structure by a user, and determining a corresponding target node and child nodes and/or father nodes of the target node;
and S103, based on node checking operation of a user, updating the current checking state of the target node by using a main thread, and updating the child nodes step by using a plurality of child threads and/or updating the father nodes step by using a plurality of child threads.
In this embodiment, a tree structure is first created for a data set, and when a user performs a checking operation on the tree structure, a corresponding target node is determined according to the checking operation, and a child node and/or a parent node of the target node are obtained in the tree structure, and then the target node is checked and updated, and the child node and/or the parent node are updated downward. Here, it will be understood that, before the operation of the user is not received, since the position of the target node in the tree structure is not determined, the target node may have both a child node and a parent node, or only a child node or only a parent node, for example, when the target node belongs to the initial node of the tree structure, only a child node exists, and thus only a child node needs to be updated. In addition, the data set described in this embodiment is a data set in software and an operating system, a data set using a file system, or the like.
In the embodiment, when the checking operation on the tree structure is performed, the quick response to the checking operation on the tree structure can be realized by checking the child node downwards and checking the parent node upwards. According to the embodiment, the situation of user operation is fully considered, the data (such as the target node) which is visible to the user and the data (such as the child node which is not unfolded under the target node) which is not visible to the user are skillfully subjected to segmentation processing, and the data which is visible to the user is updated in the main thread, so that the operation of the user can be ensured to be synchronously refreshed in time, good use experience is formed, and the data which is not visible is updated in a multithreading starting mode, so that the occurrence of clamping under a large data volume is avoided.
In an actual application scenario, the node state updating method of the tree structure provided by the embodiment is realized based on the programming language Objective-C and the Xcode as a compiling tool.
In one embodiment, the step S101 includes:
creating a structural body parentNode with the TreeNode type for the data set, and storing a father node in the data set by using the structural body parentNode;
creating a first array of folderNodes, and storing folder nodes in the dataset by using the first array of folderNodes;
creating a second array of fileNodes, and storing file nodes in the data set by using the first array of fileNodes;
creating a Boolean variable isExpanded, and storing whether nodes in the tree structure are expanded or not by using the Boolean variable isExpanded.
In this embodiment, when creating a tree structure for a data set, a structure named TreeNode is first created, representing nodes in the tree structure, the structure containing the following data:
the structural body parentNode is of a TreeNode type and is used for storing a father node to which the node belongs;
a first array folderNodes, which is used for storing the folder nodes (the type is Treenode) under the node;
the second group of fileNodes is used for storing file nodes (the type is TreeNodes) under the nodes;
the boolean variable isExpanded is used to save whether the node is expanded.
In one embodiment, as shown in fig. 2, the step S103 includes: steps S201 to S203.
S201, if the current checking state of the target node is a full checking state, updating the current checking state of the target node to an unchecked state;
s202, if the current checking state of the target node is an unchecked state, updating the current checking state of the target node into a full-selected state;
s203, correspondingly updating the child nodes of the target node according to the updated checking state; and correspondingly updating the father node of the target node according to the updated checking state.
In this embodiment, when the user performs the checking operation, if the current checking state of the target node is the full checking state, the current checking state of the target node is updated to the non-checking state according to the checking operation, and correspondingly, if the current checking state of the target node is the non-checking state, the full checking state is updated according to the checking operation. After updating the target node, the child node and the parent node are continuously updated, and when the child node and the parent node are updated, the half-selected state is related to the full-selected state and the unordered state. For example, if there are 10 subfiles and 10 subfolders under folder a, and 5 files and 1 folder are checked, folder a is in the half-selected state. That is, as long as the folder a has files and folders that are checked, the checked number is less than 10 files and 10 folders, and the folder a is in the half-selected state.
In connection with fig. 5, after the user clicks the left side tick button of the snmpconf-data, the software needs to update the button to the full or no tick state (depending on the state of the current node), and to update all files, folders under the snmpconf-data to the tick or no tick state (update child nodes down). Meanwhile, the parent node state of the snmpconf-data needs to be updated (the parent node is updated upwards), whether the snmp is fully selected or not selected (whether fileNodes, folderNodes of the snmp is all selected or not selected) needs to be judged, if so, the snmp is updated to be fully selected or not selected, the snmpconf-data is not updated to be half selected, and the snmp is updated upwards to the usr parent node.
In one embodiment, as shown in fig. 3, the step S203 includes: steps S301 to S307.
S301, respectively creating a data stack, a first temporary variable node and a node set, assigning the target node to the first temporary variable node, and storing the undeployed subfolder nodes of the first temporary variable node by using the node set;
s302, performing cycle judgment on the first temporary variable node;
s303, if the first temporary variable node is judged to be empty, finishing updating the child node;
s304, if the first temporary variable node is judged not to be empty, traversing a file array fileNodes of the first temporary variable node, and updating the picking states of all corresponding subfiles; traversing the folder array folderNodes of the first temporary variable node, updating the picking states of all the corresponding subfolders, and judging whether each subfolder is unfolded or not;
s305, when the subfolder is judged to be unfolded, adding the subfolder to the data stack;
s306, when the subfolder is judged not to be unfolded, adding the subfolder to the node set, and traversing file nodes and/or folder nodes under the subfolder to synchronously update the hooked state;
s307, carrying out the pop operation on the data stack, assigning the pop data to the first temporary variable node, and then continuously and circularly judging whether the first temporary variable node is empty or not until the first temporary variable node is empty.
When the child nodes are updated, the embodiment firstly creates a data stack (a data structure of first-in last-out), simultaneously creates a first temporary variable node, assigns the currently-hooked target node to the node, and creates a node set for storing child folder nodes of which the node variables are not expanded; and then circularly judging whether the node is empty, and ending the update when the node is empty. When the node is not empty, on one hand, traversing the node file array fileNodes, updating all the sub-file checking states, and on the other hand, traversing the folder array folderNodes, and judging whether the node sub-folder is unfolded or not when updating the sub-folder checking states (when the node is unfolded, the node is unfolded). If the node subfolder is unfolded, the subfolder is stacked, if the node subfolder is not unfolded, the subfolder is added to the nodeSet, then the nodes of the files/folders under the subfolder are traversed, and the state is synchronously updated and checked, so that the state is prevented from being updated synchronously when a user clicks to view the files/folders. And carrying out a stack-stripping operation on the data stack, assigning the data which is subjected to stack-stripping to a variable node, and then continuously and circularly judging whether the node is empty or not until the node is empty, and ending updating.
Through the updating process, the operation node and the child node which are unfolded and displayed can be ensured, and the correct checking state can be displayed after the interface is refreshed. For the child nodes which are not unfolded, the user cannot see the nodes, so that updating of the nodes does not need to be executed in the main thread, and the problem that the interface is blocked under the condition that the data volume of the nodes is large can be prevented, and the response rate of the checking operation is improved.
In some specific embodiments, the step S306 includes:
creating a second temporary variable dispatchNode, traversing the node set nodeSet to extract single file nodes and/or folder nodes, and assigning the file nodes and/or folder nodes to the second temporary variable dispatchNode;
circularly judging whether the second temporary variable dispatchNode is empty or not;
when the second temporary variable dispatchNode is judged not to be empty, updating the file node and/or the checking state of the folder node of the second temporary variable dispatchNode, and performing a push operation after updating is completed;
performing a pop operation on the data stack, and assigning the pop data to the second temporary variable dispatchNode;
and when the second temporary variable dispatchNode is judged to be empty, ending the cycle, and stopping traversing the node set.
For the subfolder/folder nodes of the undeployed node, when performing the checking update, the embodiment first creates a second temporary variable dispatchNode, then traverses the node set nodeSet, and starts the child thread to assign the single node data to the dispatchNode. Then, circularly judging whether the dispatchNode is empty, and ending the cycle when the dispatchNode is empty; when the dispatchNode is not empty, updating the sub-file/folder hook state of the dispatchNode, and pushing the sub-file into a stack. And performing stack stripping operation on the data stack, assigning the stripped data to a variable dispatchNode, and then continuously and circularly judging whether the dispatchNode is empty or not until the dispatchNode is empty, ending the circulation and performing nodeSet traversal.
In this embodiment, when updating the undeployed node, different numbers of sub-threads are started according to the size of the node set, so as to ensure the updating efficiency. For example, the node set contains 10 folders, then 10 sub-threads are started to execute, and each thread is responsible for updating one folder, so that the updating efficiency is improved.
In an embodiment, as shown in fig. 4, the step S203 further includes: steps S401 to S406.
S401, creating a third temporary variable pNode, and assigning a father node of the target node to the third temporary variable pNode;
s402, circularly judging whether the third temporary variable pNodepNode is empty or not;
s403, if the third temporary variable pNode is judged to be empty, finishing updating the father node;
s404, if the third temporary variable pNode is judged not to be empty, traversing a subfile array fileNodes of the third temporary variable pNode, and acquiring the current checking state of the subfiles; traversing subfolder array folderNodes of the third temporary variable pNode, and obtaining the current checking state of the subfolder;
s405, when the current checking state of the subfiles or subfolders is all checked, updating a third temporary variable pNode to a full-selected state; when the current checking state of the subfile is not checked, updating a third temporary variable pNode to be in the unchecked state; when the current checking state of the subfiles is a partial checking state, updating a third temporary variable pNode to a half-checking state;
s406, assigning the father node of the third temporary variable pNode to the third temporary variable pNode, and continuing to circularly judge whether the third temporary variable pNodepNode is empty or not until the third temporary variable pNode is judged to be empty.
When the parent node is updated upwards, the embodiment firstly creates a third temporary variable pNode, and assigns the parent node parentNode of the currently-checked target node to the temporary variable pNode. Then circularly judging whether the pNode is empty, and ending updating when the pNode is empty; when the pNode is not empty, traversing the pNode subfile array fileNodes on one hand, and judging whether all subfiles are checked, or not checked, or only a part of the subfiles are checked, namely half-checked; and traversing the array folderNodes of the pNode subfolders to judge whether all subfolders are checked, or not checked, or only a part of subfolders are checked, namely half-checked. If all the subfiles/folders are checked, updating the pNode to be fully selected; if the subfiles/folders are not checked, updating the pNode to be unchecked; if the subfiles/subfiles only select a portion, the pNode is updated to half-select. And then, assigning the pantnode of the pNode to the pNode, and continuously and circularly judging whether the pNode is empty or not until the pNode is empty, and ending updating.
It should be noted that, because the expansion operation of the user is limited, a large amount of data does not occur, and the node that is checked by the user is already displayed in the interface, the embodiment may be executed in the main thread when the parent node is updated upwards, and may of course also be executed in the child thread.
In an embodiment, the node status updating device of the tree structure further includes:
creating an NSOutLineView instance;
setting a node TreeNode in the tree structure as a data source of the NSOutleView instance;
and calling a loading function reloadData loading display interface in the NSOutleView instance, and receiving the checking operation of the user on the tree structure node based on the display interface.
In this embodiment, in order to facilitate user operation and interface display, an operation interface structure may be created, specifically, an instance of NSOutlineView (using row and column formats in a Cocoa development framework to display hierarchical data, such as a directory and a file that can be expanded and folded) may be created first, then a root node TreeNode in a tree structure is used as a data source of the NSOutlineView instance, and meanwhile, a main program is used as a proxy object of the NSOutlineView (responsible for assembling and displaying, adding constraints between interfaces, etc.), and then a loading function reloadData of the NSOutlineView instance is called to load a display interface. Through the created operation interface structure, the user experience degree can be further improved.
Fig. 6 is a schematic block diagram of a node status updating apparatus 600 with a tree structure according to an embodiment of the present invention, where the apparatus 600 includes:
a structure creation unit 601 for creating a tree structure of a data set; the tree structure comprises nodes corresponding to each level of files of the data set;
an operation response unit 602, configured to determine a corresponding target node and a child node and/or a parent node of the target node in response to a node hooking operation of a user on the tree structure;
the node updating unit 603 is configured to update the current checking state of the target node by using the main thread based on a node checking operation of the user, and update the child node by using a plurality of child threads step by step and/or update the parent node by step upward according to the updated checking state.
In an embodiment, the structure creating unit 601 includes:
a structure creating unit, configured to create a structure parthenonode with a TreeNode type for the data set, and store a parent node in the data set by using the structure parthenonode;
the first array creating unit is used for creating a first array folderNodes and storing the folder nodes in the data set by using the first array folderNodes;
a second array creating unit, configured to create a second array fileNodes, and store file nodes in the dataset by using the first array fileNodes;
and the variable creating unit is used for creating a Boolean variable isExpanded and storing whether the nodes in the tree structure are unfolded or not by using the Boolean variable isExpanded.
In one embodiment, as shown in fig. 7, the node update unit 603 includes:
a first updating unit 701, configured to update, if the current checking state of the target node is a full checking state, the current checking state of the target node to an unchecked state;
a second updating unit 702, configured to update the current checking state of the target node to a full-selection state if the current checking state of the target node is an unchecked state;
a parent-child updating unit 703, configured to correspondingly update child nodes of the target node according to the updated check state; and correspondingly updating the father node of the target node according to the updated checking state.
In one embodiment, as shown in fig. 8, the parent-child update unit 703 includes:
a data stack creation unit 801, configured to create a data stack, a first temporary variable node, and a node set, respectively, assign the target node to the first temporary variable node, and save a subfolder node that is not expanded by the first temporary variable node by using the node set;
a first loop judgment unit 802, configured to perform loop judgment on the first temporary variable node;
a first determining unit 803, configured to end updating the child node if it is determined that the first temporary variable node is empty;
a second determining unit 804, configured to traverse the file array fileNodes of the first temporary variable node and update the picking states of all corresponding subfiles if it is determined that the first temporary variable node is not empty; traversing the folder array folderNodes of the first temporary variable node, updating the picking states of all the corresponding subfolders, and judging whether each subfolder is unfolded or not;
a data stack adding unit 805, configured to add the subfolder to the data stack when it is determined that the subfolder is expanded;
a set adding unit 806, configured to add the subfolder to the node set and traverse the file node and/or the folder node under the subfolder to synchronously update the hooked state when it is determined that the subfolder is not expanded;
a first pop assignment unit 807, configured to perform a pop operation on the data stack, assign the pop data to the first temporary variable node, and then continue to circularly determine whether the first temporary variable node is empty until the first temporary variable node is empty.
In an embodiment, the set adding unit 806 includes:
the node extraction unit is used for creating a second temporary variable dispatchNode, traversing the node set to extract single file nodes and/or folder nodes, and assigning the file nodes and/or the folder nodes to the second temporary variable dispatchNode;
the second circulation judging unit is used for circularly judging whether the second temporary variable dispatchNode is empty or not;
the updating and stacking unit is used for updating the file node and/or the checking state of the file folder node of the second temporary variable dispatchNode when the second temporary variable dispatchNode is judged not to be empty, and performing stacking operation after the updating is completed;
the second stack-stripping assignment unit is used for carrying out stack-stripping operation on the data stack and assigning stack-stripping data to the second temporary variable dispatchNode;
and the traversal stopping unit is used for ending the circulation and stopping traversing the node set when the second temporary variable dispatchNode is judged to be empty.
In one embodiment, as shown in fig. 9, the parent-child update unit 703 further includes:
a node assignment unit 901, configured to create a third temporary variable pNode, and assign a parent node of the target node to the third temporary variable pNode;
a third loop determining unit 902, configured to loop determine whether the third temporary variable pNodepNode is empty;
a third determining unit 903, configured to end updating the parent node if it is determined that the third temporary variable pNode is empty;
a fourth determining unit 904, configured to traverse the subfile array fileNodes of the third temporary variable pNode and obtain a current checking state of the subfiles if it is determined that the third temporary variable pNode is not empty; traversing subfolder array folderNodes of the third temporary variable pNode, and obtaining the current checking state of the subfolder;
a variable updating unit 905, configured to update the third temporary variable pNode to a full selection state when the current selection state of the subfiles or subfolders is full selection; when the current checking state of the subfile is not checked, updating a third temporary variable pNode to be in the unchecked state; when the current checking state of the subfiles is a partial checking state, updating a third temporary variable pNode to a half-checking state;
and a judging ending unit 906, configured to assign the father node of the third temporary variable pNode to the third temporary variable pNode, and continue to circularly judge whether the third temporary variable pNode is empty or not until the third temporary variable pNode is judged to be empty.
In an embodiment, the node status updating apparatus 600 of the tree structure further includes:
an instance creation unit for creating an NSOutLineView instance;
the data source setting unit is used for setting a node TreeNode in the tree structure as a data source of the NSOutleView instance;
and the operation receiving unit is used for calling a loading function reloadData loading display interface in the NSOutLineView instance and receiving the checking operation of the tree structure node by a user based on the display interface.
Since the embodiments of the apparatus portion and the embodiments of the method portion correspond to each other, the embodiments of the apparatus portion are referred to the description of the embodiments of the method portion, and are not repeated herein.
The embodiment of the present invention also provides a computer readable storage medium having a computer program stored thereon, which when executed can implement the steps provided in the above embodiment. The storage medium may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RandomAccess Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The embodiment of the invention also provides a computer device, which can comprise a memory and a processor, wherein the memory stores a computer program, and the processor can realize the steps provided by the embodiment when calling the computer program in the memory. Of course, the computer device may also include various network interfaces, power supplies, and the like.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section. It should be noted that it would be obvious to those skilled in the art that various improvements and modifications can be made to the present application without departing from the principles of the present application, and such improvements and modifications fall within the scope of the claims of the present application.
It should also be noted that in this specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A node state updating method of a tree structure, comprising:
creating a tree structure of the dataset; the tree structure comprises nodes corresponding to each level of files of the data set;
responding to node checking operation of a user on the tree structure, and determining a corresponding target node and child nodes and/or father nodes of the target node;
based on node checking operation of a user, updating the current checking state of the target node by using a main thread, and updating the child nodes step by step and/or updating the father nodes step by step upwards by using a plurality of child threads according to the updated checking state.
2. The method for updating a node state of a tree structure according to claim 1, wherein the creating a tree structure of a data set comprises:
creating a structural body parentNode with the TreeNode type for the data set, and storing a father node in the data set by using the structural body parentNode;
creating a first array of folderNodes, and storing folder nodes in the dataset by using the first array of folderNodes;
creating a second array of fileNodes, and storing file nodes in the data set by using the first array of fileNodes;
creating a Boolean variable isExpanded, and storing whether nodes in the tree structure are expanded or not by using the Boolean variable isExpanded.
3. The method for updating a node state of a tree structure according to claim 2, wherein the step of updating the current checking state of the target node by using the main thread based on the node checking operation of the user, and step-by-step updating the child node by using a plurality of child threads and/or step-by-step updating the parent node upward according to the updated checking state comprises:
if the current checking state of the target node is the full checking state, updating the current checking state of the target node into an unchecked state;
if the current checking state of the target node is not checked, updating the current checking state of the target node into a full-checking state;
correspondingly updating the child node of the target node according to the updated checking state; and correspondingly updating the father node of the target node according to the updated checking state.
4. A method for updating a node state of a tree structure according to claim 3, wherein the correspondingly updating the child node of the target node according to the updated checking state includes:
respectively creating a data stack, a first temporary variable node and a node set node, assigning the target node to the first temporary variable node, and storing the undeployed subfolder nodes of the first temporary variable node by using the node set node;
performing cyclic judgment on the first temporary variable node;
if the first temporary variable node is judged to be empty, ending updating the child node;
if the first temporary variable node is judged not to be empty, traversing a file array fileNodes of the first temporary variable node, and updating the checking states of all corresponding subfiles; traversing the folder array folderNodes of the first temporary variable node, updating the picking states of all the corresponding subfolders, and judging whether each subfolder is unfolded or not;
when the subfolder is judged to be unfolded, adding the subfolder to the data stack;
when the subfolder is judged not to be unfolded, adding the subfolder to the node set, and traversing file nodes and/or folder nodes under the subfolder to synchronously update the checked state;
and carrying out the pop operation on the data stack, assigning the pop data to the first temporary variable node, and then continuously and circularly judging whether the first temporary variable node is empty or not until the first temporary variable node is empty.
5. The method for updating a node state of a tree structure according to claim 4, wherein when the subfolder is determined not to be expanded, adding the subfolder to the node set, and traversing the file nodes and/or the folder nodes under the subfolder to synchronously update the checkpointed state, comprises:
creating a second temporary variable dispatchNode, traversing the node set nodeSet to extract single file nodes and/or folder nodes, and assigning the file nodes and/or folder nodes to the second temporary variable dispatchNode;
circularly judging whether the second temporary variable dispatchNode is empty or not;
when the second temporary variable dispatchNode is judged not to be empty, updating the file node and/or the checking state of the folder node of the second temporary variable dispatchNode, and performing a push operation after updating is completed;
performing a pop operation on the data stack, and assigning the pop data to the second temporary variable dispatchNode;
and when the second temporary variable dispatchNode is judged to be empty, ending the cycle, and stopping traversing the node set.
6. A method for updating a node state of a tree structure according to claim 3, wherein the correspondingly updating the parent node of the target node according to the updated tick state comprises:
creating a third temporary variable pNode, and assigning a father node of the target node to the third temporary variable pNode;
circularly judging whether the third temporary variable pNodepNode is empty or not;
if the third temporary variable pNode is judged to be empty, ending updating of the father node;
if the third temporary variable pNode is judged not to be empty, traversing a subfile array fileNodes of the third temporary variable pNode, and acquiring the current checking state of the subfiles; traversing subfolder array folderNodes of the third temporary variable pNode, and obtaining the current checking state of the subfolder;
when the current checking state of the subfiles or subfolders is all checked, updating the third temporary variable pNode to be in a full-selected state; when the current checking state of the subfile is not checked, updating a third temporary variable pNode to be in the unchecked state; when the current checking state of the subfiles is a partial checking state, updating a third temporary variable pNode to a half-checking state;
and assigning the father node of the third temporary variable pNode to the third temporary variable pNode, and continuously and circularly judging whether the third temporary variable pNodepNode is empty or not until the third temporary variable pNode is judged to be empty.
7. The method for updating a node state of a tree structure according to claim 2, further comprising:
creating an NSOutLineView instance;
setting a node TreeNode in the tree structure as a data source of the NSOutleView instance;
and calling a loading function reloadData loading display interface in the NSOutleView instance, and receiving the checking operation of the user on the tree structure node based on the display interface.
8. A node state updating apparatus of a tree structure, comprising:
a structure creation unit for creating a tree structure of the data set; the tree structure comprises nodes corresponding to each level of files of the data set;
an operation response unit, configured to determine a corresponding target node and a child node and/or a parent node of the target node in response to a node hooking operation of a user on the tree structure;
and the node updating unit is used for updating the current checking state of the target node by utilizing the main thread based on the node checking operation of the user, and updating the child nodes step by step and/or updating the father nodes step by step upwards by utilizing a plurality of child threads according to the updated checking state.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of updating the node state of the tree structure of any of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the tree-structured node status updating method according to any of claims 1 to 7.
CN202410030758.3A 2024-01-09 2024-01-09 Node state updating method and device of tree structure and related medium Pending CN117827845A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410030758.3A CN117827845A (en) 2024-01-09 2024-01-09 Node state updating method and device of tree structure and related medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410030758.3A CN117827845A (en) 2024-01-09 2024-01-09 Node state updating method and device of tree structure and related medium

Publications (1)

Publication Number Publication Date
CN117827845A true CN117827845A (en) 2024-04-05

Family

ID=90505828

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410030758.3A Pending CN117827845A (en) 2024-01-09 2024-01-09 Node state updating method and device of tree structure and related medium

Country Status (1)

Country Link
CN (1) CN117827845A (en)

Similar Documents

Publication Publication Date Title
US9189513B1 (en) Distributed, transactional key-value store
US20140310245A1 (en) Partition level backup and restore of a massively parallel processing database
EP3961431B1 (en) Method and apparatus for grouping transactions that need to be serially executed based on a sequence of transactions in one block of a blockchain
CN109643309A (en) System and method for executing range query to jump list data structure
CN111324577B (en) Yml file reading and writing method and device
US20090259618A1 (en) Slicing of relational databases
CN112948039A (en) Page display method, device, equipment and storage medium
CN117150095B (en) Hierarchical tree node searching method, electronic equipment and medium
CN117194739B (en) Method, electronic equipment and medium for searching hierarchical tree nodes based on hit state
CN111190768B (en) Database execution error recovery method, database access method and device
CN117827845A (en) Node state updating method and device of tree structure and related medium
CN109189343B (en) Metadata disk-dropping method, device, equipment and computer-readable storage medium
CN113792026B (en) Method and device for deploying database script and computer-readable storage medium
CN115086757B (en) Method, device, equipment and storage medium for withdrawing history editing operation
CN106648550B (en) Method and device for concurrently executing tasks
Paksula Persisting objects in redis key-value database
CN115374128B (en) Method and device for importing Excel into database, computer equipment and medium
CN110688387A (en) Data processing method and device
CN117076725B (en) Method, electronic device and medium for searching tree nodes based on underlying data
CN112950378B (en) Method and device for executing intelligent contract in block chain
CN114036058A (en) Software automation test method and device
CN115543966A (en) Concurrent migration method, device, equipment and storage medium of database structure
CN111813440A (en) Multithreading application issuing method and device
CN116303248A (en) Data migration method of distributed file system and related components
CN114780075A (en) Code frame generation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination