Search Results

Search found 5101 results on 205 pages for 'expression trees'.

Page 14/205 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Efficient (basic) regular expression implementation for streaming data

    - by Brendan Dolan-Gavitt
    I'm looking for an implementation of regular expression matching that operates on a stream of data -- i.e., it has an API that allows a user to pass in one character at a time and report when a match is found on the stream of characters seen so far. Only very basic (classic) regular expressions are needed, so a DFA/NFA based implementation seems like it would be well-suited to the problem. Based on the fact that it's possible to do regular expression matching using a DFA/NFA in a single linear sweep, it seems like a streaming implementation should be possible. Requirements: The library should try to wait until the full string has been read before performing the match. The data I have really is streaming; there is no way to know how much data will arrive, it's not possible to seek forward or backward. Implementing specific stream matching for a couple special cases is not an option, as I don't know in advance what patterns a user might want to look for. For the curious, my use case is the following: I have a system which intercepts memory writes inside a full system emulator, and I would like to have a way to identify memory writes that match a regular expression (e.g., one could use this to find the point in the system where a URL is written to memory). I have found (links de-linkified because I don't have enough reputation): stackoverflow.com/questions/1962220/apply-a-regex-on-stream stackoverflow.com/questions/716927/applying-a-regular-expression-to-a-java-i-o-stream www.codeguru.com/csharp/csharp/cs_data/searching/article.php/c14689/Building-a-Regular-Expression-Stream-Search-with-the-NET-Framework.htm But all of these attempt to convert the stream to a string first and then use a stock regular expression library. Another thought I had was to modify the RE2 library, but according to the author it is architected around the assumption that the entire string is in memory at the same time. If nothing's available, then I can start down the unhappy path of reinventing this wheel to fit my own needs, but I'd really rather not if I can avoid it. Any help would be greatly appreciated!

    Read the article

  • LINQ to SQL: NOTing a prebuilt expression

    - by ck
    I'm building a library of functions for one of my core L2S classes, all of which return a bool to allow checking for certain situations. Example: Expression<Func<Account, bool>> IsSomethingX = a => a.AccountSupplementary != null && a.AccountSupplementary.SomethingXFlag != null && a.AccountSupplementary.SomethingXFlag.Value; Now to query where this is not true, I CAN'T do this: var myAccounts= context.Accounts .Where(!IsSomethingX); // does not compile However, using the syntax from the PredicateBuilder class, I've come up with this: public static IQueryable<T> WhereNot<T>(this IQueryable<T> items, Expression<Func<T, bool>> expr1) { var invokedExpr = Expression.Invoke(expr1, expr1.Parameters.Cast<Expression>()); return items.Where(Expression.Lambda<Func<T, bool>> (Expression.Not(invokedExpr), expr1.Parameters)); } var myAccounts= context.Accounts .WhereNot(IsSomethingX); // does compile which actually produces the correct SQL. Does this look like a good solution, and is there anything I need to be aware of that might cause me problems in future?

    Read the article

  • Java library for trees similar to JGraphT for graphs?

    - by lexicore
    I'm a big fan of JGraphT, a Java library for graphs. Could anyone recommend a similar Java library for trees? Preferrably FOSS. What I need is a good API, preferrably typesafe with generics which allows modelling different kinds of trees (with some user data attached to verticies/edges) and run different algorithms and operations on these trees. For instance, traverse or balance. At the moment I'm not interested in visualization of trees.

    Read the article

  • How can I get objects and property values from expression trees?

    This is a follow-up to the Getting Information About Objects, Types, and Members with Expression Trees post, so I would recommend that you read that one first. Among other code examples in that blog post, I demonstrated how you can get a property name as a string by using expression trees. Here is the method. public static string GetName<T>(Expression<Func<T>> e) { var member = (MemberExpression)e.Body; return member.Member.Name; } And here is how you can use it. string...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • How can I get objects and property values from expression trees?

    This is a follow-up to the Getting Information About Objects, Types, and Members with Expression Trees post, so I would recommend that you read that one first. Among other code examples in that blog post, I demonstrated how you can get a property name as a string by using expression trees. Here is the method. public static string GetName<T>(Expression<Func<T>> e) { var member = (MemberExpression)e.Body; return member.Member.Name; } And here is how you can use it. string...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Using custom DataContractResolver in WCF, to transport inheritance trees involving generics

    - by Benson
    I've got a WCF service, in which there are operations which accept a non-generic base class as parameter. [DataContract] class Foo { ... } This base class is in turn inherited, by such generics classes as [DataContract] class Bar : Foo { ... } To get this to work, I'd previously have to register KnownTypes for the Foo class, and have these include all possible variations of Bar (such as Bar, Bar and even Bar). With the DataContractResolver in .NET 4, however, I should be able to build a resolver which properly stores (and restores) the classes. My questions: Are DataContractResolvers typically only used on the service side, and not by the client? If so, how would that be useful in this scenario? Am I wrong to write a DataContractResolver which serializes the fully qualified type name of a generic type, such as Bar1[List1[string, mscorlib], mscorlib] ? Couldn't the same DataContractResolver on the client side restore these types?

    Read the article

  • Dynamically loading sub-trees into YUI Treeview

    - by user319399
    When you create a YUI TreeView instance, you can pass in an object that represents an entire tree, and it will automatically build up the TextNodes for you. I'd like to send in a partial tree, such that the tree only goes, say, 2 levels deep, and anything deeper than that will invoke dynamic loading. I've got that much working. Now for the interesting part. In the dynamic loading callback I give to my tree instance, I want to again be able to just give YUI a big object representing more of the tree. I want to do something like this: // data is a array of objects organized into a tree, with some nodes requiring dynamic loading when they are navigated to tree = new YAHOO.widget.TreeView("treeDiv1", data); tree.setDynamicLoad(loadDataForNode); function loadDataForNode(node, onCompleteCallback) { if(node.children.length==0) { var subTree = { "label":"Cars", isLeaf:false, children:[ { "label":"Chevy", isLeaf:true }, { "label":"Ford", isLeaf:true }, ] }; // doesn't work, even though it has the required "label" field var tempNode = new YAHOO.widget.TextNode(subTree, node, true); } onCompleteCallback(); } Is this possible? Or do I have to iterate over all the nodes in my subtree and construct individual TextNodes for each one? Thanks much...

    Read the article

  • Linux Kernel - Red/Black Trees

    - by CodeRanger
    I'm trying to implement a red/black tree in Linux per task_struct using code from linux/rbtree.h. I can get a red/black tree inserting properly in a standalone space in the kernel such as a module but when I try to get the same code to function with the rb_root declared in either task_struct or task_struct-files_struct, I get a SEGFAULT everytime I try an insert. Here's some code: In task_struct I create a rb_root struct for my tree (not a pointer). In init_task.h, macro INIT_TASK(tsk), I set this equal to RB_ROOT. To do an insert, I use this code: rb_insert(&(current-fd_tree), &rbnode); This is where the issue occurs. My insert command is the standard insert that is documented in all RBTree documentation for the kernel: int my_insert(struct rb_root *root, struct mytype *data) { struct rb_node **new = &(root->rb_node), *parent = NULL; /* Figure out where to put new node */ while (*new) { struct mytype *this = container_of(*new, struct mytype, node); int result = strcmp(data->keystring, this->keystring); parent = *new; if (result < 0) new = &((*new)->rb_left); else if (result > 0) new = &((*new)->rb_right); else return FALSE; } /* Add new node and rebalance tree. */ rb_link_node(&data->node, parent, new); rb_insert_color(&data->node, root); return TRUE; } Is there something I'm missing? Some reason this would work fine if I made a tree root outside of task_struct? If I make rb_root inside of a module this insert works fine. But once I put the actual tree root in the task_struct or even in the task_struct-files_struct, I get a SEGFAULT. Can a root node not be added in these structs? Any tips are greatly appreciated. I've tried nearly everything I can think of.

    Read the article

  • Red-Black trees - Erasing a node with two non-leaf children

    - by SalamiArmi
    Hi all, I've been implementing my own version of a red-black tree, mostly basing my algorithms from Wikipedia (http://en.wikipedia.org/wiki/Red-black_tree). Its fairly concise for the most part, but there's one part that I would like clarification on. When erasing a node from the tree that has 2 non-leaf (non-NULL) children, it says to move either side's children into the deletable node, and remove that child. I'm a little confused as to which side to remove from, based on that. Do I pick the side randomly, do I alternate betweek sides, or do I stick to the same side for every future deletion?

    Read the article

  • Repeated Scene Trees (Java3d / OpenGL)

    - by Jim
    Hello, I want to make a 3d scene that loops around on its self. That is to say, if you keep going in any direction, you will loop back to the other side. My current implementation is so bad, it's embarrassing to admit to it. I redraw the each change twenty-seven times, to make a 3x3x3 scene cube. When the user reaches the end of the middle cube, I jump them over to the other side. Maintaining consistency (let alone performance) is a nightmare. Total Disaster. This doesn't seem like it would be an unusual request, so I'm wondering if anyone knows of a more legit solution. Thanks!

    Read the article

  • Insertions into Zipper trees on XML files in Clojure

    - by ivar
    I'm confused as how to idiomatically change a xml tree accessed through clojure.contrib's zip-filter.xml. Should be trying to do this at all, or is there a better way? Say that I have some dummy xml file "itemdb.xml" like this: <itemlist> <item id="1"> <name>John</name> <desc>Works near here.</desc> </item> <item id="2"> <name>Sally</name> <desc>Owner of pet store.</desc> </item> </itemlist> And I have some code: (require '[clojure.zip :as zip] '[clojure.contrib.duck-streams :as ds] '[clojure.contrib.lazy-xml :as lxml] '[clojure.contrib.zip-filter.xml :as zf]) (def db (ref (zip/xml-zip (lxml/parse-trim (java.io.File. "itemdb.xml"))))) ;; Test that we can traverse and parse. (doall (map #(print (format "%10s: %s\n" (apply str (zf/xml-> % :name zf/text)) (apply str (zf/xml-> % :desc zf/text)))) (zf/xml-> @db :item))) ;; I assume something like this is needed to make the xml tags (defn create-item [name desc] {:tag :item :attrs {:id "3"} :contents (list {:tag :name :attrs {} :contents (list name)} {:tag :desc :attrs {} :contents (list desc)})}) (def fred-item (create-item "Fred" "Green-haired astrophysicist.")) ;; This disturbs the structure somehow (defn append-item [xmldb item] (zip/insert-right (-> xmldb zip/down zip/rightmost) item)) ;; I want to do something more like this (defn append-item2 [xmldb item] (zip/insert-right (zip/rightmost (zf/xml-> xmldb :item)) item)) (dosync (alter db append-item2 fred-item)) ;; Save this simple xml file with some added stuff. (ds/spit "appended-itemdb.xml" (with-out-str (lxml/emit (zip/root @db) :pad true))) I am unclear about how to use the clojure.zip functions appropriately in this case, and how that interacts with zip-filter. If you spot anything particularly weird in this small example, please point it out.

    Read the article

  • B-trees that use redistribution on insertion

    - by Phenom
    If I insert the following keys into a B-tree of order 4 (meaning 4 pointers and 3 elements in each node), I get the following B-tree. G / \ A IY Would it look any different if redistribution on insertion were used? How does redistribution on insertion work?

    Read the article

  • Deeply nested subqueries for traversing trees in MySQL

    - by nickf
    I have a table in my database where I store a tree structure using the hybrid Nested Set (MPTT) model (the one which has lft and rght values) and the Adjacency List model (storing parent_id on each node). my_table (id, parent_id, lft, rght, alias) This question doesn't relate to any of the MPTT aspects of the tree but I thought I'd leave it in in case anyone had a good idea about how to leverage that. I want to convert a path of aliases to a specific node. For example: "users.admins.nickf" would find the node with alias "nickf" which is a child of one with alias "admins" which is a child of "users" which is at the root. There is a unique index on (parent_id, alias). I started out by writing the function so it would split the path to its parts, then query the database one by one: SELECT `id` FROM `my_table` WHERE `parent_id` IS NULL AND `alias` = 'users';-- 1 SELECT `id` FROM `my_table` WHERE `parent_id` = 1 AND `alias` = 'admins'; -- 8 SELECT `id` FROM `my_table` WHERE `parent_id` = 8 AND `alias` = 'nickf'; -- 37 But then I realised I could do it with a single query, using a variable amount of nesting: SELECT `id` FROM `my_table` WHERE `parent_id` = ( SELECT `id` FROM `my_table` WHERE `parent_id` = ( SELECT `id` FROM `my_table` WHERE `parent_id` IS NULL AND `alias` = 'users' ) AND `alias` = 'admins' ) AND `alias` = 'nickf'; Since the number of sub-queries is dependent on the number of steps in the path, am I going to run into issues with having too many subqueries? (If there even is such a thing) Are there any better/smarter ways to perform this query?

    Read the article

  • Tortoise SVN diff two trees

    - by Midhat
    Hi Consider the following situation Code was added to the trunk at revision x A branch was created The modifications of rev x were removed from trunk in rev x+10 trunk and branch goes their own ways till rev x+100 Now we need to update the branch with changes form the trunk The problem with a simple "merge a range of revisions" is that due to step 3, the initial branch modifications are being removed. Is there any way to work around this without resorting to manual merge. Version Info: TortoiseSVN 1.6.7, Build 18415 - 32 Bit , 2010/01/22 17:55:06 Subversion 1.6.9,

    Read the article

  • How to find longest common substring using trees?

    - by user384706
    The longest common substring problem according to wiki can be solved using a suffix tree. From wiki: The longest common substrings of a set of strings can be found by building a generalised suffix tree for the strings, and then finding the deepest internal nodes which have leaf nodes from all the strings in the subtree below it I don't get this. Example: if I have: ABCDE and XABCZ then the suffix tree is (some branches from XABCZ omitted due to space): The longest common substring is ABC but it is not I can not see how the description of wiki helps here. ABC is not the deepest internal nodes with leaf nodes. Any help to understand how this works?

    Read the article

  • Data structure for unrooted trees

    - by Esmond
    I'm having problems figuring out how to build an unrooted tree with weighted edges and what data structure to store such a tree. An example of an unrooted tree would be like the one here: http://www.bio.davidson.edu/courses/GENOMICS/seq/unrooted.gif The problem i am having is the leaves would only have 1 link to the internal nodes and the internal nodes would have 3 links(the internal nodes would have 2 children and a link to another internal node). Do i have to distinguish between the 2 different kinds of nodes or can i have one class having the function of both types of nodes?

    Read the article

  • merging 3 source versioned trees into 1

    - by user309779
    This is probably an easy question... I have 4 source versions of the same software in 4 different directories. I have just started using git for version control. To date, I have just been snapping a desperate copy rolling forward. I want to merge all versions (1.0.0.1, 1.0.0.2, 1.0.0.3, 1.0.1.0) together so that I will have a reference history. Opposed to just starting out with 1.0.1.0 as the initial version. I want to get this sort of thing right form the start. Can someone outline the basic steps to accomplish this? Thanks much, XO

    Read the article

  • In B-trees which element gets promoted when the node splits

    - by Phenom
    Let's say there is a B-tree of order 8. This means it can have 8 pointers and 7 elements. Say the letters A through G are stored in this B-tree. So this B-tree is just a single node containing 7 elements. Then you try to insert J into the tree. There's no room, so you have to split the node and create a new root node. Which element gets promoted up into the root node?

    Read the article

  • Evaluate cron expression

    - by Jake A. Smith
    Is there a command line tool that will simply evaluate a cron expression and return a bool response if it is supposed to be running right now? I'm looking for something I can use as a utility in another bash script. Something like so: run_script=$(/tools/evaluate-cron-expression "02 4 * * *") if [ "$run_script" -eq "1" ] # etc etc I know, I know, I could just setup a real cron job, but I'm playing with the idea of wrapping all of my scheduled scripts inside of another script.

    Read the article

  • Notepad ++ regular expression

    - by arvindwill
    have javascript file will millions of lines. The problem is IE dont support ','(comma) followed by '}'(curly close bracket) by using notepadd++ need to find all the comma which is followed by curly close bracket. So regular expression \,.*\} works. but the problem between the comma and close bracket many tab space or newline or linefeed can be there . cant able to provide the newline with spaces in regular expression. like below one somestring, }

    Read the article

  • Can I use relative XPath expressions in libxml2?

    - by brbr
    I am wondering whether it is possible to use relative XPath expressions in libxml2. This is from the javax.xml.xpath API and I would like to do the similar thing using libxml2: Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE); With a reference to the element, a relative XPath expression can now written to select the child element: XPath xpath = XPathFactory.newInstance().newXPath(); String expression = "manufacturer"; Node manufacturerNode = (Node) xpath.evaluate(expression, **widgetNode**, XPathConstants.NODE);

    Read the article

  • What is the easiest way to get the property value from a passed lambda expression in an extension me

    - by Andrew Siemer
    I am writing a dirty little extension method for HtmlHelper so that I can say something like HtmlHelper.WysiwygFor(lambda) and display the CKEditor. I have this working currently but it seems a bit more cumbersome than I would prefer. I am hoping that there is a more straight forward way of doing this. Here is what I have so far. public static MvcHtmlString WysiwygFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression) { return MvcHtmlString.Create(string.Concat("<textarea class=\"ckeditor\" cols=\"80\" id=\"", expression.MemberName(), "\" name=\"editor1\" rows=\"10\">", GetValue(helper, expression), "</textarea>")); } private static string GetValue<TModel, TProperty>(HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression) { MemberExpression body = (MemberExpression)expression.Body; string propertyName = body.Member.Name; TModel model = helper.ViewData.Model; string value = typeof(TModel).GetProperty(propertyName).GetValue(model, null).ToString(); return value; } private static string MemberName<T, V>(this Expression<Func<T, V>> expression) { var memberExpression = expression.Body as MemberExpression; if (memberExpression == null) throw new InvalidOperationException("Expression must be a member expression"); return memberExpression.Member.Name; } Thanks!

    Read the article

  • New regular expression features in PCRE 8.34 and 8.35

    - by Jan Goyvaerts
    PCRE 8.34 adds some new regex features and changes the behavior of a few to make it better compatible with the latest versions of Perl. There are no changes to the regex syntax in PCRE 8.35. \o{377} is now an octal escape just like \377. This syntax was first introduced in Perl 5.12. It avoids any confusion between octal escapes and backreferences. It also allows octal numbers beyond 377 to be used. E.g. \o{400} is the same as \x{100}. If you have any reason to use octal escapes instead of hexadecimal escapes then you should definitely use the new syntax. Because of this change, \o is now an error when it doesn’t form a valid octal escape. Previously \o was a literal o and \o{377} was a sequence of 337 o‘s. In free-spacing mode, whitespace between a quantifier and the ? that makes it lazy or the + that makes it possessive is now ignored. In Perl this has always been the case. In PCRE 8.33 and prior, whitespace ended a quantifier and any following ? or + was seen as a second quantifier and thus an error. The shorthand \s now matches the vertical tab character in addition to the other whitespace characters it previously matched. Perl 5.18 made the same change. Many other regex flavors have always included the vertical tab in \s, just like POSIX has always included it in [[:space:]]. Names of capturing groups are no longer allowed to start with a digit. This has always been the case in Perl since named groups were added to Perl 5.10. PCRE 8.33 and prior even allowed group names to consist entirely of digits. [[:<:]] and [[::]] are now treated as POSIX-style word boundaries. They match at the start and the end of a word. Though they use similar syntax, these have nothing to do with POSIX character classes and cannot be used inside character classes. Perl does not support POSIX word boundaries. The same changes affect PHP 5.5.10 (and later) and R 3.0.3 (and later) as they have been updated to use PCRE 8.34. RegexBuddy and RegexMagic have been updated to support the latest versions of PCRE, PHP, and R. Older versions that were previously supported are still supported, so you can compare or convert your regular expressions between the latest versions of PCRE, PHP, and R and whichever version you were using previously.

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >