Search Results

Search found 6420 results on 257 pages for 'mathieu parent'.

Page 49/257 | < Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >

  • iPhone. How to get the rect of parent view?

    - by flexbyte
    Hi, My application creates two views: topView (CGRect = 0,0, 320,60) bottomView (CGRect = 0,60, 320,480) Bottom view creates UITabBarController with UIViewControllers: ListViewController etc... ListViewController has own views that are created in viewDidLoad method: background = [[UIImageView alloc] initWithFrame: rect ]; So my question is how to get the bottomView rect inside ListViewController? I want to layout all controller views without intersection with topView. Thank you.

    Read the article

  • Persisting object changes from child form to parent form based on button press.

    - by Shyran
    I have created a form that is used for both adding and editing a custom object. Which mode the form takes is provided by an enum value passed from the calling code. I also pass in an object of the custom type. All of my controls at data bound to the specific properties of the custom object. When the form is in Add mode, this works great as when the controls are updated with data, the underlying object is as well. However, in Edit mode, I keep two variables of the custom object supplied by the calling code, the original, and a temporary one made through deep copying. The controls are then bound to the temporary copy, this makes it easy to discard the changes if the user clicks the Cancel button. What I want to know is how to persist those changes back to the original object if the user clicks the OK button, since there is now a disconnect because of the deep copying. I am trying to avoid implementing a internal property on the Add/Edit form if I can. Below is an example of my code: public AddEditCustomerDialog(Customer customer, DialogMode mode) { InitializeComponent(); InitializeCustomer(customer, mode); } private void InitializeCustomer(Customer customer, DialogMode mode) { this.customer = customer; if (mode == DialogMode.Edit) { this.Text = "Edit Customer"; this.tempCustomer = ObjectCopyHelper.DeepCopy(this.customer); this.customerListBindingSource.DataSource = this.tempCustomer; this.phoneListBindingSource.DataSource = this.tempCustomer.PhoneList; } else { this.customerListBindingSource.DataSource = this.customer; this.phoneListBindingSource.DataSource = this.customer.PhoneList; } }

    Read the article

  • How can I get all children from a parent row in the same table?

    - by Johnny Freeman
    Let's say I have a table called my_table that looks like this: id | name | parent_id 1 | Row 1 | NULL 2 | Row 2 | NULL 3 | Row 3 | 1 4 | Row 4 | 1 5 | Row 5 | NULL 6 | Row 6 | NULL 7 | Row 7 | 8 8 | Row 8 | NULL 9 | Row 9 | 4 10 | Row 10 | 4 Basically I want my final array in PHP to look like this: Array ( [0] => Array ( [name] => Row 1 [children] => Array ( [0] => Array ( [name] => Row 3 [children] => ) [1] => Array ( [name] => Row 4 [children] => Array ( [0] => Array ( [name] => Row 9 [children] => ) [1] => Array ( [name] => Row 10 [children] => ) ) ) ) ) [1] => Array ( [name] => Row 2 [children] => ) [2] => Array ( [name] => Row 5 [children] => ) [3] => Array ( [name] => Row 6 [children] => ) [4] => Array ( [name] => Row 8 [children] => Array ( [0] => Array ( [name] => Row 7 [children] => ) ) ) ) So, I want it to get all of the rows where parent_id is null, then find all nested children recursively. Now here's the part that I'm having trouble with: How can this be done with 1 call to the database? I'm sure I could do it with a simple select statement and then have PHP make the array look like this but I'm hoping this can be done with some kind of fancy db joining or something like that. Any takers?

    Read the article

  • How to access a method of a closure's parent object?

    - by Bytecode Ninja
    I have defined a class named MyClass and I have defined two methods myMethod1 and myMethod2 for it: function MyClass() {} MyClass.prototype.myMethod1 = function() {...}; MyClass.prototype.myMethod2 = function() {...}; Inside myMethod1, I use jQuery and there's a callback closure defined there: MyClass.prototype.myMethod2 = function() { $.jQuery({success: function(data) { this.myMethod2(); }, ...}); } Now the problem is that this no longer is referring to MyClass. The question is how can I refer to it? At the moment I have assigned it to a variable named thisObj and access it this way: MyClass.prototype.myMethod2 = function() { var thisObj = this; $.jQuery({success: function(data) { thisObj.myMethod2(); }, ...}); } Is there a better way to access MyClass.this from the closure nested in myMethod2? Thanks in advance.

    Read the article

  • jQuery apply functionality only to class and parent elements.

    - by kylex
    I have the following list: <ul> <li class="topCurrent">One <ul> <li>One-1 <ul> <li>One-1.1 <ul> <li class="current">One-1.1.1 <ul> <li>One-1.1.1.1</li> <li>One-1.1.1.2</li> <li>One-1.1.1.3</li> </ul> </li> <li>One-1.1.2</li> </ul> </li> <li>One-1.2</li> </ul> </li> <li>One-2</li> <li>One-3</li> </ul> </li> <li>Two <ul> <li>Two-1</li> <li>Two-2</li> </ul> </li> Using the following jQuery: $("ul li ul").hide(); $("ul li").hoverIntent( function(){ $(this).children('ul').slideDown('fast'); }, function(){ $(this).children('ul').slideUp('fast'); } ); What this does is hide all of the ul below the top level ul until there is a hover over it. What I would like to do is this: If an li has a class="current" I would like that structure to be open up until the point that current is hit. It would still allow the ul below it to be displayed on a hover, as well as any other ul's, but at no point would the parents of class="current" be hidden. Suggestions? This problem has been driving me crazy. Thanks!

    Read the article

  • How can I call a function in a parent movieclip from an externally-loaded child?

    - by Doug Wolfgram
    I have a swf file that is my 'shell' program that contains many functions. This shell program loads child movies. In the root timeline of the child movie, I have the following code: function putresponse(q,r) { trace (r); _root.debug(r); } _root.debug("foo"); Debug is a function that writes some text to the screen. When I run this locally, the putresponse function gets called and the trace happens. When I run it remotely (inside the shell) the first debug happens immediately on load (as you'd expect) but then later when putresponse is called, the debug(r) is not executed. The external clip is at the same url as the shell so I don't think it is a security issue. Also, as I said, the debug("foo") works fine. This one really has me perplexed. Can anyone shed some light as to why I can't call the debug from _root when called from a function rather than on the first-level timeline? EDIT: The call to putresponse is coming form two layers deep in local (within the child MC) MCs. The actual call is: _parent._parent.putrepsonse(q,r);

    Read the article

  • How to access constant defined in child class from parent class functions?

    - by kavoir.com
    I saw this example from php.net: <?php class MyClass { const MY_CONST = "yonder"; public function __construct() { $c = get_class( $this ); echo $c::MY_CONST; } } class ChildClass extends MyClass { const MY_CONST = "bar"; } $x = new ChildClass(); // prints 'bar' $y = new MyClass(); // prints 'yonder' ?> But $c::MY_CONST is only recognized in version 5.3.0 or later. The class I'm writing may be distributed a lot. Basically, I have defined a constant in ChildClass and one of the functions in MyClass (father class) needs to use the constant. Any idea?

    Read the article

  • Collision detection on sub views contained in 2 separate parent UIViews?

    - by Chris
    Hi All, I originally setup some conditions using CGRectIntersectsRect for some collision detection which worked fine. In the greater scale of things I only need part of the view to be detected. So originally within the ViewController it was comparing 2 UIviews. Now what I need to do is collision detection of subViews within 2 different UIViews that are contained in a view in which the view controller does the logic. My script is no longer working as I suspect CGRectIntersectsRect only compares frames within the same view? I'll keep digging to confirm this. Any ways around this? Is it possible for example to get the x and y pos of the sub view in relation to the main view that's performing the logic?

    Read the article

  • Apache mod_rewrite : How to REWRITE (or whatever) child directories to parent?

    - by ????
    Actually i am trying to make a PHP MVC like application. A basic one. The current milestone i am reaching already includes: Basic RESTful Routing Means, if i type: www.example.com/items/book/8888 .. it properly just stays there as it is and i can already slice out the URL by slashes / and loads the responsible Controllers .... etc from the top single index.php file. I mean, so it is OK for the backend PHP. But the only problem is, it still CAN NOT process the REWRITES properly. For example, the CSS & JS are BROKEN as if i VIEW PAGE SOURCE of the page www.example.com/items/book/8888, the asset files are being called as: www.example.com/items/book/8888/css/main.css www.example.com/items/book/8888/js/jquery.js .. which really are PROBLEMS because in the code is like: <link type="text/css" rel="stylesheet" media="all" href="css/main.css"> <script type="text/javascript" src="js/jquery.js"></script> So the question is: How can i use Apache REWRITE (or whatever approach) to make sure every ASSET FILES to be correctly being called from the DOCROOT. For example, if i am in the URL: www.example.com/items/book/8888 My ASSET FILES should still be called as: www.example.com/css/main.css www.example.com/js/jquery.js Or is there any other methods i need to follow? Please kindly help suggest. Thank you.

    Read the article

  • Is there any event sent to window when new tab opens from parent tab on click a anchor tag with target _blank?

    - by Justin John
    I need to write callback function on clicking an anchor with target="_blank". <a rel="external" href="http://twitter.com/" target="_blank"> <img src="twitter.png"> </a> I think, following code block will do it. $("a[target='_blank']").click(function() { // action required }); Is there any other way where we can get an event with new tab opens? For example: The unload event is sent to the window element when the user navigates away from the page. If I think same perspective, Is there any event sent to window when a new tab opens.

    Read the article

  • exporting bind and keyframe bone poses from blender to use in OpenGL

    - by SaldaVonSchwartz
    I'm having a hard time trying to understand how exactly Blender's concept of bone transforms maps to the usual math of skinning (which I'm implementing in an OpenGL-based engine of sorts). Or I'm missing out something in the math.. It's gonna be long, but here's as much background as I can think of. First, a few notes and assumptions: I'm using column-major order and multiply from right to left. So for instance, vertex v transformed by matrix A and then further transformed by matrix B would be: v' = BAv. This also means whenever I export a matrix from blender through python, I export it (in text format) in 4 lines, each representing a column. This is so I can then I can read them back into my engine like this: if (fscanf(fileHandle, "%f %f %f %f", &skeleton.joints[currentJointIndex].inverseBindTransform.m[0], &skeleton.joints[currentJointIndex].inverseBindTransform.m[1], &skeleton.joints[currentJointIndex].inverseBindTransform.m[2], &skeleton.joints[currentJointIndex].inverseBindTransform.m[3])) { if (fscanf(fileHandle, "%f %f %f %f", &skeleton.joints[currentJointIndex].inverseBindTransform.m[4], &skeleton.joints[currentJointIndex].inverseBindTransform.m[5], &skeleton.joints[currentJointIndex].inverseBindTransform.m[6], &skeleton.joints[currentJointIndex].inverseBindTransform.m[7])) { if (fscanf(fileHandle, "%f %f %f %f", &skeleton.joints[currentJointIndex].inverseBindTransform.m[8], &skeleton.joints[currentJointIndex].inverseBindTransform.m[9], &skeleton.joints[currentJointIndex].inverseBindTransform.m[10], &skeleton.joints[currentJointIndex].inverseBindTransform.m[11])) { if (fscanf(fileHandle, "%f %f %f %f", &skeleton.joints[currentJointIndex].inverseBindTransform.m[12], &skeleton.joints[currentJointIndex].inverseBindTransform.m[13], &skeleton.joints[currentJointIndex].inverseBindTransform.m[14], &skeleton.joints[currentJointIndex].inverseBindTransform.m[15])) { I'm simplifying the code I show because otherwise it would make things unnecessarily harder (in the context of my question) to explain / follow. Please refrain from making remarks related to optimizations. This is not final code. Having said that, if I understand correctly, the basic idea of skinning/animation is: I have a a mesh made up of vertices I have the mesh model-world transform W I have my joints, which are really just transforms from each joint's space to its parent's space. I'll call these transforms Bj meaning matrix which takes from joint j's bind pose to joint j-1's bind pose. For each of these, I actually import their inverse to the engine, Bj^-1. I have keyframes each containing a set of current poses Cj for each joint J. These are initially imported to my engine in TQS format but after (S)LERPING them I compose them into Cj matrices which are equivalent to the Bjs (not the Bj^-1 ones) only that for the current spacial configurations of each joint at that frame. Given the above, the "skeletal animation algorithm is" On each frame: check how much time has elpased and compute the resulting current time in the animation, from 0 meaning frame 0 to 1, meaning the end of the animation. (Oh and I'm looping forever so the time is mod(total duration)) for each joint: 1 -calculate its world inverse bind pose, that is Bj_w^-1 = Bj^-1 Bj-1^-1 ... B0^-1 2 -use the current animation time to LERP the componets of the TQS and come up with an interpolated current pose matrix Cj which should transform from the joints current configuration space to world space. Similar to what I did to get the world version of the inverse bind poses, I come up with the joint's world current pose, Cj_w = C0 C1 ... Cj 3 -now that I have world versions of Bj and Cj, I store this joint's world- skinning matrix K_wj = Cj_w Bj_w^-1. The above is roughly implemented like so: - (void)update:(NSTimeInterval)elapsedTime { static double time = 0; time = fmod((time + elapsedTime),1.); uint16_t LERPKeyframeNumber = 60 * time; uint16_t lkeyframeNumber = 0; uint16_t lkeyframeIndex = 0; uint16_t rkeyframeNumber = 0; uint16_t rkeyframeIndex = 0; for (int i = 0; i < aClip.keyframesCount; i++) { uint16_t keyframeNumber = aClip.keyframes[i].number; if (keyframeNumber <= LERPKeyframeNumber) { lkeyframeIndex = i; lkeyframeNumber = keyframeNumber; } else { rkeyframeIndex = i; rkeyframeNumber = keyframeNumber; break; } } double lTime = lkeyframeNumber / 60.; double rTime = rkeyframeNumber / 60.; double blendFactor = (time - lTime) / (rTime - lTime); GLKMatrix4 bindPosePalette[aSkeleton.jointsCount]; GLKMatrix4 currentPosePalette[aSkeleton.jointsCount]; for (int i = 0; i < aSkeleton.jointsCount; i++) { F3DETQSType& lPose = aClip.keyframes[lkeyframeIndex].skeletonPose.jointPoses[i]; F3DETQSType& rPose = aClip.keyframes[rkeyframeIndex].skeletonPose.jointPoses[i]; GLKVector3 LERPTranslation = GLKVector3Lerp(lPose.t, rPose.t, blendFactor); GLKQuaternion SLERPRotation = GLKQuaternionSlerp(lPose.q, rPose.q, blendFactor); GLKVector3 LERPScaling = GLKVector3Lerp(lPose.s, rPose.s, blendFactor); GLKMatrix4 currentTransform = GLKMatrix4MakeWithQuaternion(SLERPRotation); currentTransform = GLKMatrix4Multiply(currentTransform, GLKMatrix4MakeTranslation(LERPTranslation.x, LERPTranslation.y, LERPTranslation.z)); currentTransform = GLKMatrix4Multiply(currentTransform, GLKMatrix4MakeScale(LERPScaling.x, LERPScaling.y, LERPScaling.z)); if (aSkeleton.joints[i].parentIndex == -1) { bindPosePalette[i] = aSkeleton.joints[i].inverseBindTransform; currentPosePalette[i] = currentTransform; } else { bindPosePalette[i] = GLKMatrix4Multiply(aSkeleton.joints[i].inverseBindTransform, bindPosePalette[aSkeleton.joints[i].parentIndex]); currentPosePalette[i] = GLKMatrix4Multiply(currentPosePalette[aSkeleton.joints[i].parentIndex], currentTransform); } aSkeleton.skinningPalette[i] = GLKMatrix4Multiply(currentPosePalette[i], bindPosePalette[i]); } } At this point, I should have my skinning palette. So on each frame in my vertex shader, I do: uniform mat4 modelMatrix; uniform mat4 projectionMatrix; uniform mat3 normalMatrix; uniform mat4 skinningPalette[6]; attribute vec4 position; attribute vec3 normal; attribute vec2 tCoordinates; attribute vec4 jointsWeights; attribute vec4 jointsIndices; varying highp vec2 tCoordinatesVarying; varying highp float lIntensity; void main() { vec3 eyeNormal = normalize(normalMatrix * normal); vec3 lightPosition = vec3(0., 0., 2.); lIntensity = max(0.0, dot(eyeNormal, normalize(lightPosition))); tCoordinatesVarying = tCoordinates; vec4 skinnedVertexPosition = vec4(0.); for (int i = 0; i < 4; i++) { skinnedVertexPosition += jointsWeights[i] * skinningPalette[int(jointsIndices[i])] * position; } gl_Position = projectionMatrix * modelMatrix * skinnedVertexPosition; } The result: The mesh parts that are supposed to animate do animate and follow the expected motion, however, the rotations are messed up in terms of orientations. That is, the mesh is not translated somewhere else or scaled in any way, but the orientations of rotations seem to be off. So a few observations: In the above shader notice I actually did not multiply the vertices by the mesh modelMatrix (the one which would take them to model or world or global space, whichever you prefer, since there is no parent to the mesh itself other than "the world") until after skinning. This is contrary to what I implied in the theory: if my skinning matrix takes vertices from model to joint and back to model space, I'd think the vertices should already be premultiplied by the mesh transform. But if I do so, I just get a black screen. As far as exporting the joints from Blender, my python script exports for each armature bone in bind pose, it's matrix in this way: def DFSJointTraversal(file, skeleton, jointList): for joint in jointList: poseJoint = skeleton.pose.bones[joint.name] jointTransform = poseJoint.matrix.inverted() file.write('Joint ' + joint.name + ' Transform {\n') for col in jointTransform.col: file.write('{:9f} {:9f} {:9f} {:9f}\n'.format(col[0], col[1], col[2], col[3])) DFSJointTraversal(file, skeleton, joint.children) file.write('}\n') And for current / keyframe poses (assuming I'm in the right keyframe): def exportAnimations(filepath): # Only one skeleton per scene objList = [object for object in bpy.context.scene.objects if object.type == 'ARMATURE'] if len(objList) == 0: return elif len(objList) > 1: return #raise exception? dialog box? skeleton = objList[0] jointNames = [bone.name for bone in skeleton.data.bones] for action in bpy.data.actions: # One animation clip per action in Blender, named as the action animationClipFilePath = filepath[0 : filepath.rindex('/') + 1] + action.name + ".aClip" file = open(animationClipFilePath, 'w') file.write('target skeleton: ' + skeleton.name + '\n') file.write('joints count: {:d}'.format(len(jointNames)) + '\n') skeleton.animation_data.action = action keyframeNum = max([len(fcurve.keyframe_points) for fcurve in action.fcurves]) keyframes = [] for fcurve in action.fcurves: for keyframe in fcurve.keyframe_points: keyframes.append(keyframe.co[0]) keyframes = set(keyframes) keyframes = [kf for kf in keyframes] keyframes.sort() file.write('keyframes count: {:d}'.format(len(keyframes)) + '\n') for kfIndex in keyframes: bpy.context.scene.frame_set(kfIndex) file.write('keyframe: {:d}\n'.format(int(kfIndex))) for i in range(0, len(skeleton.data.bones)): file.write('joint: {:d}\n'.format(i)) joint = skeleton.pose.bones[i] jointCurrentPoseTransform = joint.matrix translationV = jointCurrentPoseTransform.to_translation() rotationQ = jointCurrentPoseTransform.to_3x3().to_quaternion() scaleV = jointCurrentPoseTransform.to_scale() file.write('T {:9f} {:9f} {:9f}\n'.format(translationV[0], translationV[1], translationV[2])) file.write('Q {:9f} {:9f} {:9f} {:9f}\n'.format(rotationQ[1], rotationQ[2], rotationQ[3], rotationQ[0])) file.write('S {:9f} {:9f} {:9f}\n'.format(scaleV[0], scaleV[1], scaleV[2])) file.write('\n') file.close() Which I believe follow the theory explained at the beginning of my question. But then I checked out Blender's directX .x exporter for reference.. and what threw me off was that in the .x script they are exporting bind poses like so (transcribed using the same variable names I used so you can compare): if joint.parent: jointTransform = poseJoint.parent.matrix.inverted() else: jointTransform = Matrix() jointTransform *= poseJoint.matrix and exporting current keyframe poses like this: if joint.parent: jointCurrentPoseTransform = joint.parent.matrix.inverted() else: jointCurrentPoseTransform = Matrix() jointCurrentPoseTransform *= joint.matrix why are they using the parent's transform instead of the joint in question's? isn't the join transform assumed to exist in the context of a parent transform since after all it transforms from this joint's space to its parent's? Why are they concatenating in the same order for both bind poses and keyframe poses? If these two are then supposed to be concatenated with each other to cancel out the change of basis? Anyway, any ideas are appreciated.

    Read the article

  • Binary Search Tree Implementation

    - by Gabe
    I've searched the forum, and tried to implement the code in the threads I found. But I've been working on this real simple program since about 10am, and can't solve the seg. faults for the life of me. Any ideas on what I'm doing wrong would be greatly appreciated. BST.h (All the implementation problems should be in here.) #ifndef BST_H_ #define BST_H_ #include <stdexcept> #include <iostream> #include "btnode.h" using namespace std; /* A class to represent a templated binary search tree. */ template <typename T> class BST { private: //pointer to the root node in the tree BTNode<T>* root; public: //default constructor to make an empty tree BST(); /* You have to document these 4 functions */ void insert(T value); bool search(const T& value) const; bool search(BTNode<T>* node, const T& value) const; void printInOrder() const; void remove(const T& value); //function to print out a visual representation //of the tree (not just print the tree's values //on a single line) void print() const; private: //recursive helper function for "print()" void print(BTNode<T>* node,int depth) const; }; /* Default constructor to make an empty tree */ template <typename T> BST<T>::BST() { root = NULL; } template <typename T> void BST<T>::insert(T value) { BTNode<T>* newNode = new BTNode<T>(value); cout << newNode->data; if(root == NULL) { root = newNode; return; } BTNode<T>* current = new BTNode<T>(NULL); current = root; current->data = root->data; while(true) { if(current->left == NULL && current->right == NULL) break; if(current->right != NULL && current->left != NULL) { if(newNode->data > current->data) current = current->right; else if(newNode->data < current->data) current = current->left; } else if(current->right != NULL && current->left == NULL) { if(newNode->data < current->data) break; else if(newNode->data > current->data) current = current->right; } else if(current->right == NULL && current->left != NULL) { if(newNode->data > current->data) break; else if(newNode->data < current->data) current = current->left; } } if(current->data > newNode->data) current->left = newNode; else current->right = newNode; return; } //public helper function template <typename T> bool BST<T>::search(const T& value) const { return(search(root,value)); //start at the root } //recursive function template <typename T> bool BST<T>::search(BTNode<T>* node, const T& value) const { if(node == NULL || node->data == value) return(node != NULL); //found or couldn't find value else if(value < node->data) return search(node->left,value); //search left subtree else return search(node->right,value); //search right subtree } template <typename T> void BST<T>::printInOrder() const { //print out the value's in the tree in order // //You may need to use this function as a helper //and create a second recursive function //(see "print()" for an example) } template <typename T> void BST<T>::remove(const T& value) { if(root == NULL) { cout << "Tree is empty. No removal. "<<endl; return; } if(!search(value)) { cout << "Value is not in the tree. No removal." << endl; return; } BTNode<T>* current; BTNode<T>* parent; current = root; parent->left = NULL; parent->right = NULL; cout << root->left << "LEFT " << root->right << "RIGHT " << endl; cout << root->data << " ROOT" << endl; cout << current->data << "CURRENT BEFORE" << endl; while(current != NULL) { cout << "INTkhkjhbljkhblkjhlk " << endl; if(current->data == value) break; else if(value > current->data) { parent = current; current = current->right; } else { parent = current; current = current->left; } } cout << current->data << "CURRENT AFTER" << endl; // 3 cases : //We're looking at a leaf node if(current->left == NULL && current->right == NULL) // It's a leaf { if(parent->left == current) parent->left = NULL; else parent->right = NULL; delete current; cout << "The value " << value << " was removed." << endl; return; } // Node with single child if((current->left == NULL && current->right != NULL) || (current->left != NULL && current->right == NULL)) { if(current->left == NULL && current->right != NULL) { if(parent->left == current) { parent->left = current->right; cout << "The value " << value << " was removed." << endl; delete current; } else { parent->right = current->right; cout << "The value " << value << " was removed." << endl; delete current; } } else // left child present, no right child { if(parent->left == current) { parent->left = current->left; cout << "The value " << value << " was removed." << endl; delete current; } else { parent->right = current->left; cout << "The value " << value << " was removed." << endl; delete current; } } return; } //Node with 2 children - Replace node with smallest value in right subtree. if (current->left != NULL && current->right != NULL) { BTNode<T>* check; check = current->right; if((check->left == NULL) && (check->right == NULL)) { current = check; delete check; current->right = NULL; cout << "The value " << value << " was removed." << endl; } else // right child has children { //if the node's right child has a left child; Move all the way down left to locate smallest element if((current->right)->left != NULL) { BTNode<T>* leftCurrent; BTNode<T>* leftParent; leftParent = current->right; leftCurrent = (current->right)->left; while(leftCurrent->left != NULL) { leftParent = leftCurrent; leftCurrent = leftCurrent->left; } current->data = leftCurrent->data; delete leftCurrent; leftParent->left = NULL; cout << "The value " << value << " was removed." << endl; } else { BTNode<T>* temp; temp = current->right; current->data = temp->data; current->right = temp->right; delete temp; cout << "The value " << value << " was removed." << endl; } } return; } } /* Print out the values in the tree and their relationships visually. Sample output: 22 18 15 10 9 5 3 1 */ template <typename T> void BST<T>::print() const { print(root,0); } template <typename T> void BST<T>::print(BTNode<T>* node,int depth) const { if(node == NULL) { std::cout << std::endl; return; } print(node->right,depth+1); for(int i=0; i < depth; i++) { std::cout << "\t"; } std::cout << node->data << std::endl; print(node->left,depth+1); } #endif main.cpp #include "bst.h" #include <iostream> using namespace std; int main() { BST<int> tree; cout << endl << "LAB #13 - BINARY SEARCH TREE PROGRAM" << endl; cout << "----------------------------------------------------------" << endl; // Insert. cout << endl << "INSERT TESTS" << endl; // No duplicates allowed. tree.insert(0); tree.insert(5); tree.insert(15); tree.insert(25); tree.insert(20); // Search. cout << endl << "SEARCH TESTS" << endl; int x = 0; int y = 1; if(tree.search(x)) cout << "The value " << x << " is on the tree." << endl; else cout << "The value " << x << " is NOT on the tree." << endl; if(tree.search(y)) cout << "The value " << y << " is on the tree." << endl; else cout << "The value " << y << " is NOT on the tree." << endl; // Removal. cout << endl << "REMOVAL TESTS" << endl; tree.remove(0); tree.remove(1); tree.remove(20); // Print. cout << endl << "PRINTED DIAGRAM OF BINARY SEARCH TREE" << endl; cout << "----------------------------------------------------------" << endl; tree.print(); cout << endl << "Program terminated. Goodbye." << endl << endl; } BTNode.h #ifndef BTNODE_H_ #define BTNODE_H_ #include <iostream> /* A class to represent a node in a binary search tree. */ template <typename T> class BTNode { public: //constructor BTNode(T d); //the node's data value T data; //pointer to the node's left child BTNode<T>* left; //pointer to the node's right child BTNode<T>* right; }; /* Simple constructor. Sets the data value of the BTNode to "d" and defaults its left and right child pointers to NULL. */ template <typename T> BTNode<T>::BTNode(T d) : left(NULL), right(NULL) { data = d; } #endif Thanks.

    Read the article

  • NHibernate Many-To-One on Joined Sublcass with Filter

    - by Nathan Roe
    I have a class setup that looks something like this: public abstract class Parent { public virtual bool IsDeleted { get; set; } } public class Child : Parent { } public class Other { public virtual ICollection<Child> Children { get; set; } } Child is mapped as a joined-subclass of Parent. Childen is mapped as a Many-To-One bag. The bag has a filter applied to it named SoftDeletableFilter. The filter mapping looks like: <filter-def name="SoftDeleteableFilter" condition="(IsDeleted = 0 or IsDeleted is null)" /> That problem is that when Other.Children is loaded the filter is being applied to the Child table and not the parent table. Is there any way to tell NHibernate to apply the filter to the parent class?

    Read the article

  • How can I use a TreeWalker to dump out the DOM

    - by michael
    Hi, In w3c dom interface, there is DOMTreeWalker to traverse the DOM. I find this example which uses DOMTreeWalker: http://www.java-tips.org/java-se-tips/org.w3c.dom/how-to-traverse-the-dom-tree-using-treewalker-2.html But my question is How can I use the DOMTreeWalk to dump the dom structure and value to a file? i.e. I need to know when a parent start and a parent end so that I can do when I dump the dom to a file (i need to insert after each parent dumps its children: <parent> <child a1="1" a2="2"/> <child a3="1" a4="3"/> <child a5="1" a6="5"/> </parent>

    Read the article

  • Short hand for number of tags having lengthier [and almost same] Xpath

    - by infant programmer
    For example : this is an xslt <xsl:template match="/root/sub-root/parent/child/grand_child/dummy1/dummy2/dummy3/dummy4/node_1 |/root/sub-root/parent/child/grand_child/dummy1/dummy2/dummy3/dummy4/node_2 |/root/sub-root/parent/child/grand_child/dummy1/dummy2/dummy3/dummy4/node_3 . . |/root/sub-root/parent/child/grand_child/dummy1/dummy2/dummy3/dummy4/node_N"/> In the above code can I use the XPath /root/sub-root/parent/child/grand_child/dummy1/dummy2/dummy3/dummy4 only once [use the braces or whatever] and reduce the bulkiness of the code? As you can see, all the nodes are siblings of each-other, so except their name their Xpath is same. Is there any short-hand property ? Does XSLT 1.0 (or Xpath1.0) allows it?

    Read the article

  • Jquery - Get all other menus to slide up

    - by Jova
    I have a drop down menu made with Jquery. Right now, if you hover over all the menu items, their submenus will all show at the same time. I would like that if I hover over one menu, then go to the next, that the previous menu's submenu will slide back up. As it is now, I have to hover out of the submenus for them to slide up. To put it simpler, when hovering over a parent menu, slide up all other parent menu's submenus if they're open. $("#DropDownMenu li.parent").hover(function() { $(this).find(".subMenu").slideDown('fast').show(); $(this).parent().find(".subMenu").hover(function() { }, function() { $(this).parent().find(".subMenu").slideUp('slow'); }); });

    Read the article

< Previous Page | 45 46 47 48 49 50 51 52 53 54 55 56  | Next Page >