Search Results

Search found 224 results on 9 pages for 'traversal'.

Page 3/9 | < Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >

  • Multithreaded linked list traversal

    - by Rob Bryce
    Given a (doubly) linked list of objects (C++), I have an operation that I would like multithread, to perform on each object. The cost of the operation is not uniform for each object. The linked list is the preferred storage for this set of objects for a variety of reasons. The 1st element in each object is the pointer to the next object; the 2nd element is the previous object in the list. I have solved the problem by building an array of nodes, and applying OpenMP. This gave decent performance. I then switched to my own threading routines (based off Windows primitives) and by using InterlockedIncrement() (acting on the index into the array), I can achieve higher overall CPU utilization and faster through-put. Essentially, the threads work by "leap-frog'ing" along the elements. My next approach to optimization is to try to eliminate creating/reusing the array of elements in my linked list. However, I'd like to continue with this "leap-frog" approach and somehow use some nonexistent routine that could be called "InterlockedCompareDereference" - to atomically compare against NULL (end of list) and conditionally dereference & store, returning the dereferenced value. I don't think InterlockedCompareExchangePointer() will work since I cannot atomically dereference the pointer and call this Interlocked() method. I've done some reading and others are suggesting critical sections or spin-locks. Critical sections seem heavy-weight here. I'm tempted to try spin-locks but I thought I'd first pose the question here and ask what other people are doing. I'm not convinced that the InterlockedCompareExchangePointer() method itself could be used like a spin-lock. Then one also has to consider acquire/release/fence semantics... Ideas? Thanks!

    Read the article

  • Dom Traversal to Automate Keyboard Focus - Spatial Navigation

    - by Steve
    I'm going to start with a little background that will hopefully help my question make more sense. I am developing an application for a television. The concept is simple and basically works by overlaying a browser over the video plane of the TV. Now being a TV, there is no mouse or additional pointing device. All interaction is done through a remote control. Therefore, the user needs to be able to visually tell which element they are currently focused upon. To indicate that an element is focused, I currently append a colored transparent image over the element to indicate focus. Now, when a user hits the arrow keys, I need to respond by focusing on the correct elements according to the key pressed. So, if the down arrow is pressed I need to focus on the next focusable element in the DOM tree (which may be a child or sibling), and if they hit the up arrow, I need to respond to the previous element. This would essentially simulate spatial navigation within a browser. I am currently setting an attribute (focusable=true) on any DOM elements that should be able to receive focus. What I would like to do is determine the previous or next focusable element (i.e. attribute focusable=true) and apply focus to the element. I was hoping to traverse the DOM tree to determine the next and previously focusable elements, but I am not sure how to perform this in JQuery, or in general. I was leaning towards trying to use the JQuery tree travesal methods like next(), prev(), etc. What approach would you take to solve this type of issue? Thanks

    Read the article

  • Prototype - DOM Traversal with up()

    - by Jason McCreary
    I have the following structure: <form> <div class="content"> ... </div> <div class="action"> <p>Select <a class="select_all" href="?select=1" title="Select All">All</a></p> </div> </form> I am using Prototype's up() to traverse the DOM in order to find the <form> element in respect to the a.select_all. However the following doesn't work: select_link.up('form'); // returns undefined Yet, this does. select_link.up().up().up(); // returns HTMLFormElement Clearly this is an ancestor of a.select_all. The API Docs state Element.up() supports a CSSRule. What am I missing here?

    Read the article

  • jquery - DOM traversal question

    - by David
    Hi, Basically what I have here is a button that adds a new list item to an unordered list. Within this list item is a dropdown box (.formSelector) that when changed triggers an ajax call to get the values for another dropdown box (.fieldSelector) in the same list item. The problem is on this line: $(this).closest(".fieldSelector").append( If I change it to $(".fieldSelector").append( the second box updates correctly. The problem with this is that when I have multiple list items it updates every dropdown box on the page with the class fieldSelector, which is undesirable. How can I traverse the DOM to just pick the fieldSelector in the current list item? Any help is greatly appreciated. Complete code: $("button", "#newReportElement").click(function() { $("#reportElements").append("<li class=\"ui-state-default\"> <span class=\"test ui-icon ui-icon-arrowthick-2-n-s \"></span><span class=\"ui-icon ui-icon-trash deleteRange \"></span> <select name=\"form[]\" class=\"formSelector\"><? foreach ($forms->result() as $row) { echo "<option value='$row->formId'>$row->name</option>"; }?></select><select class=\"fieldSelector\" name=\"field[]\"></select></li>"); $(".deleteRange").button(); $('.formSelector').change(function() { var id = $(this).val(); var url = "<? echo site_url("report/formfields");?>" + "/" + id; var atext = "ids:"; $.getJSON(url, function(data){ $.each(data.items, function(i,item){ $(this).closest(".fieldSelector").append( $('<option></option>').val(item.formId).html(item.formLabel) ); }); }); }); return false; });

    Read the article

  • Binary Search Tree, cannot do traversal

    - by ihm
    Please see BST codes below. It only outputs "5". what did I do wrong? #include <iostream> class bst { public: bst(const int& numb) : root(new node(numb)) {} void insert(const int& numb) { root->insert(new node(numb), root); } void inorder() { root->inorder(root); } private: class node { public: node(const int& numb) : left(NULL), right(NULL) { value = numb; } void insert(node* insertion, node* position) { if (position == NULL) position = insertion; else if (insertion->value > position->value) insert(insertion, position->right); else if (insertion->value < position->value) insert(insertion, position->left); } void inorder(node* tree) { if (tree == NULL) return; inorder(tree->left); std::cout << tree->value << std::endl; inorder(tree->right); } private: node* left; node* right; int value; }; node* root; }; int main() { bst tree(5); tree.insert(4); tree.insert(2); tree.insert(10); tree.insert(14); tree.inorder(); return 0; }

    Read the article

  • grid traversal question

    - by Kensay
    Given a grid of any height and width, write an algorithm to traverse it in a spiral. (Starting at the top left and ending in the middle) without passing over previously visited nodes. Without using nested loops.

    Read the article

  • directory traversal in Java using different regular and enhanced for loops

    - by user3245621
    I have this code to print out all directories and files. I tried to use recursive method call in for loop. With enhanced for loop, the code prints out all the directories and files correctly. But with regular for loop, the code does not work. I am puzzled by the difference between regular and enhanced for loops. public class FileCopy { private File[] childFiles = null; public static void main(String[] args) { FileCopy fileCopy = new FileCopy(); File srcFile = new File("c:\\temp"); fileCopy.copyTree(srcFile); } public void copyTree(File file){ if(file.isDirectory()){ System.out.println(file + " is a directory. "); childFiles = file.listFiles(); /*for(int j=0; j<childFiles.length; j++){ copyTree(childFiles[j]); } This part is not working*/ for(File a: childFiles){ copyTree(a); } return; } else{ System.out.println(file + " is a file. "); return; } } }

    Read the article

  • reconstructing a tree from its preorder and postorder lists.

    - by NomeN
    Consider the situation where you have two lists of nodes of which all you know is that one is a representation of a preorder traversal of some tree and the other a representation of a postorder traversal of the same tree. I believe it is possible to reconstruct the tree exactly from these two lists, and I think I have an algorithm to do it, but have not proven it. As this will be a part of a masters project I need to be absolutely certain that it is possible and correct (Mathematically proven). However it will not be the focus of the project, so I was wondering if there is a source out there (i.e. paper or book) I could quote for the proof. (Maybe in TAOCP? anybody know the section possibly?) In short, I need a proven algorithm in a quotable resource that reconstructs a tree from its pre and post order traversals. Note: The tree in question will probably not be binary, or balanced, or anything that would make it too easy. Note2: Using only the preorder or the postorder list would be even better, but I do not think it is possible. Note3: A node can have any amount of children. Note4: I only care about the order of siblings. Left or right does not matter when there is only one child.

    Read the article

  • Running multiple services on Port 443, Tunnel SSH over HTTPS

    - by lajuette
    Situation: I want to tunnel SSH sessions through HTTPS. I have a very restrictive firewall/proxy which only allows HTTP, FTP and HTTPS traffic. What works: Setting up a tunnel through the proxy to a remote linux box that has a sshd listening at port 443 The problem: I have to have a web server (lighty) running at port 443. HTTPS traffic to other ports is forbidden by the proxy. Ideas so far: Set up a virtual host and proxy all incoming requests to localhost: (e.g. 22) $HTTP["host"] == "tunnel.mylinux.box" { proxy.server = ( "" => (("host" => "127.0.0.1", "port" => 22)) ) } Unfortunately this won't work. Am i doing something wrong, or is there a reason, that this won't work?

    Read the article

  • SuperMicro IPMI through OpenBSD PF Firewall

    - by thelsdj
    I'm trying to access a SuperMicro IPMI card that is behind an OpenBSD bridged firewall. A couple pieces of information: The OpenBSD firewall itself has a SuperMicro IPMI that I can access across the internet. The IPMI I'm trying to reach can be reached from behind the firewall. My gateway does arp request the IPMI and it does appear to respond (this is from the external interface of the firewall) 16:57:45.548892 arp who-has ipminame tell gwname 16:57:45.549500 arp reply ipminame is-at ipmimac But when I make a request to the IPMI IP from outside the firewall the external interface of the firewall shows no traffic with the IPMI ip as its destination. Any idea what might be causing this problem? Is there something about IPMI traffic that my gateway wouldn't like (the gateway is provided by my colocation provider so I can't easily debug it).

    Read the article

  • What ports tend to be unfiltered by boneheaded firewalls?

    - by Reid
    Hi all, I like to be able to ssh into my server (shocking, I know). The problem comes when I'm traveling, where I face a variety of firewalls in hotels and other institutions, having a variety of configurations, sometimes quite boneheaded. I'd like to set up an sshd listening on a port that has a high probability of getting through this mess. Any suggestions? The sshd currently listens on a nonstandard (but < 1024) port to avoid script kiddies knocking on the door. This port is frequently blocked, as is the other nonstandard port where my IMAP server lives. I have services running on ports 25 and 80 but anything else is fair game. I was thinking 443 perhaps. Much appreciated! Reid

    Read the article

  • C++ design question on traversing binary trees

    - by user231536
    I have a binary tree T which I would like to copy to another tree. Suppose I have a visit method that gets evaluated at every node: struct visit { virtual void operator() (node* n)=0; }; and I have a visitor algorithm void visitor(node* t, visit& v) { //do a preorder traversal using stack or recursion if (!t) return; v(t); visitor(t->left, v); visitor(t->right, v); } I have 2 questions: I settled on using the functor based approach because I see that boost graph does this (vertex visitors). Also I tend to repeat the same code to traverse the tree and do different things at each node. Is this a good design to get rid of duplicated code? What other alternative designs are there? How do I use this to create a new binary tree from an existing one? I can keep a stack on the visit functor if I want, but it gets tied to the algorithm in visitor. How would I incorporate postorder traversals here ? Another functor class?

    Read the article

  • Multiple vulnerabilities in Oracle Java Web Console

    - by RitwikGhoshal
    CVE DescriptionCVSSv2 Base ScoreComponentProduct and Resolution CVE-2007-5333 Information Exposure vulnerability 5.0 Apache Tomcat Solaris 10 SPARC: 147673-04 X86: 147674-04 CVE-2007-5342 Permissions, Privileges, and Access Controls vulnerability 6.4 CVE-2007-6286 Request handling vulnerability 4.3 CVE-2008-0002 Information disclosure vulnerability 5.8 CVE-2008-1232 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability 4.3 CVE-2008-1947 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability 4.3 CVE-2008-2370 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability 5.0 CVE-2008-2938 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability 4.3 CVE-2008-5515 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability 5.0 CVE-2009-0033 Improper Input Validation vulnerability 5.0 CVE-2009-0580 Information Exposure vulnerability 4.3 CVE-2009-0781 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability 4.3 CVE-2009-0783 Information Exposure vulnerability 4.6 CVE-2009-2693 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability 5.8 CVE-2009-2901 Permissions, Privileges, and Access Controls vulnerability 4.3 CVE-2009-2902 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability 4.3 CVE-2009-3548 Credentials Management vulnerability 7.5 CVE-2010-1157 Information Exposure vulnerability 2.6 CVE-2010-2227 Improper Restriction of Operations within the Bounds of a Memory Buffer vulnerability 6.4 CVE-2010-3718 Directory traversal vulnerability 1.2 CVE-2010-4172 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability 4.3 CVE-2010-4312 Configuration vulnerability 6.4 CVE-2011-0013 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability 4.3 CVE-2011-0534 Resource Management Errors vulnerability 5.0 CVE-2011-1184 Permissions, Privileges, and Access Controls vulnerability 5.0 CVE-2011-2204 Information Exposure vulnerability 1.9 CVE-2011-2526 Improper Input Validation vulnerability 4.4 CVE-2011-3190 Permissions, Privileges, and Access Controls vulnerability 7.5 CVE-2011-4858 Resource Management Errors vulnerability 5.0 CVE-2011-5062 Permissions, Privileges, and Access Controls vulnerability 5.0 CVE-2011-5063 Improper Authentication vulnerability 4.3 CVE-2011-5064 Cryptographic Issues vulnerability 4.3 CVE-2012-0022 Numeric Errors vulnerability 5.0 This notification describes vulnerabilities fixed in third-party components that are included in Oracle's product distributions.Information about vulnerabilities affecting Oracle products can be found on Oracle Critical Patch Updates and Security Alerts page.

    Read the article

  • Using recursion to find paths in a 2D array

    - by rikkit
    Hi, I'm working on a project for my A level. It involves finding the maximum flow of a network, and I'm using javascript. I have a 2D array, with values in the array representing a distance between the two points. An example of the array: 0 2 2 0 0 0 1 2 0 0 0 2 0 0 0 0 I think I need to use a recursive technique to find a path; below is some pseudocode, assuming that the array is 4x4. a is (0,0), b is (3,3). function search(a,b) from a to b if element(i,j) != 0 then store value of element search(j,3) I was wondering if that was the right construction for a depth first search. Thanks for any help.

    Read the article

  • jQuery - Not sure which method to use, closest() and parent() don't work.

    - by Nike
    Hello, again. :) God i feel like i'm spamming stackoverflow, this is my 3rd post for today. Sorry, heh. I even posted a question regarding this before, kind of, but i've changed the code a bit since so i thought it was better to post a new question. $('.pmlist ul li h4 .toggle').click(function() { $(this).closest('.meddel').toggle(250); }); That's what i've got now. The reason why the closest() method isn't working is because the div .meddel is just next to the h4 element. And closest() only crawls right up the DOM tree, ignoring other child elements. Right? parent() works almost the same and doesn't work either. And as i only want to toggle the closest .meddel div in the element, i need something that, yeah justs grabs the nearest one, and not all of them. To clear it up a bit, here's the HTML for one list item: <li class="item"> <h4><a class="toggle">ämne</a><small>2010-04-17 kl 12:54 by <u>nike1</u></small></h4> <div class="meddel"> <span> <img style="max-width: 70%; min-height: 70%;" src="profile-images/nike1.jpg" alt="" /> <a href="account.php?usr=47">nike1</a> </span> <p>text</p> </div> </li> I have several items like that, and if i click one toggle link, i just want the nearest .meddel to be toggled, as mentioned before. Thanks. -Nike

    Read the article

  • "tracing" version of readlink(1)

    - by jonrock
    I would like a version of "readlink -f" that provides a trace of every individual symlink resolution it performs. Something like: $ linktrace /usr/lib64/sendmail /usr/lib64 -> lib /usr/lib/sendmail -> ../sbin/sendmail /usr/sbin/sendmail $ I know I have used this utility in the past, on linux, and also remember at the time thinking "the name of this tool is completely unintuitive and I will forget it". Well, that day has arrived.

    Read the article

  • How can I store data in a table as a trie? (SQL Server)

    - by Matt
    Hi, To make things easier, the table contains all the words in the English dictionary. What I would like to do is be able to store the data as a trie. This way I can traverse the different branches of the trie and return the most relevant result. First, how do I store the data in the table as a trie? Second, how do I traverse the tree? If it helps at all, the suggestion in this previous question is where this question was sparked from. Please make sure it's SQL we're talking about. I understood the Mike Dunlavey's C implementation because of pointers but can't see how this part (The trie itself) works in SQL. Thanks, Matt

    Read the article

  • Is there a way in PHP to check if a directory is a symlink?

    - by tixrus
    The title says it all. I have symlinks to certain directories because the directories' names have non English characters that I got fed up trying to get apache's rewrite rules to match. There's a bounty on that question http://stackoverflow.com/questions/2916194/trouble-with-utf-8-chars-apache2-rewrite-rulesif anyone wants to go for it, and from the looks of things a lot of people would like to see a general solution to this problem, but meanwhile I made a plain ascii symlink to each of these offending directories. Now the rewrite rules are back to just alpha and _ and - and my security concerns are less and it loads the resources I want. But I still need the actual target directory name for display purposes. I googled "PHP directory info, PHP symlink" but didn't find anything. I need to do something like this: if (is_symlink($myResDirName)) { $realDirName = follow_symlink($myResDirName); }

    Read the article

  • Numbering Regex Submatches

    - by gentlylisped
    Is there a canonical ordering of submatch expressions in a regular expression? For example: What is the order of the submatches in "(([0-9]{3}).([0-9]{3}).([0-9]{3}).([0-9]{3}))\s+([A-Z]+)" ? a. (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3}))\s+([A-Z]+) (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3})) ([A-Z]+) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) b. (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3}))\s+([A-Z]+) (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3})) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) ([0-9]{3}) ([A-Z]+) or c. somthin' else.

    Read the article

  • How to select certain child node in TreeView, C#

    - by Caslav
    I am having a problem with selecting a certain child node. What I want to achieve: I you have this treeview for example (one parent with two child nodes): Parent -Child with a value 5 -Child with a value 2. I want to add these two values and assign them to Parent node: Parent result 7 -Child 5 -Child 2. Of course, a bigger treeview would have several parents and lots of children and they will all add up to one root node. How can I do this?? pls help. thx, Caslav

    Read the article

  • find xml element by attribute

    - by Moudy
    Using JQuery or Javascript how would I return 'Mary Boone' from the xml below starting out with the show 'id' attribute of '2'? I'm thinking something along the lines of - var result = xml.getElementByAttribute("2").gallery.text(); the XML: <shows> <show id="1"> <artist>Andreas Gursky</artist> <gallery>Matthew Marks</gallery> <medium>photography</medium> </show> <show id="2"> <artist>Eric Fischl</artist> <gallery>Mary Boone</gallery> <medium>painting</medium> </show> </shows>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9  | Next Page >