Search Results

Search found 6123 results on 245 pages for 'unsigned char'.

Page 121/245 | < Previous Page | 117 118 119 120 121 122 123 124 125 126 127 128  | Next Page >

  • Shift Operators in C++

    - by Codeguru
    If the value after the shift operator is greater than the number of bits in the left-hand operand, the result is undefined. If the left-hand operand is unsigned, the right shift is a logical shift so the upper bits will be filled with zeros. If the left-hand operand is signed, the right shift may or may not be a logical shift (that is, the behavior is undefined). Can somebody explain me what the above lines mean??

    Read the article

  • Flexible array members in C - bad?

    - by Lionel
    I recently read that using flexible array members in C was poor software engineering practice. However, that statement was not backed by any argument. Is this an accepted fact? (Flexible array members are a C feature introduced in C99 whereby one can declare the last element to be an array of unspecified size. For example: ) struct header { size_t len; unsigned char data[]; };

    Read the article

  • How to interpret binary data as an integer?

    - by StackedCrooked
    The codebase at work contains some code that looks roughly like this: #define DATA_LENGTH 64 u_int32 SmartKey::SerialNumber() { unsigned char data[DATA_LENGTH]; // ... initialized data buffer return *(u_int32*)data; } This code works correctly, but GCC gives the following warning: warning: dereferencing pointer ‘serialNumber’ does break strict-aliasing rules Can someone explain this warning? Is this code potentially dangerous? How can it be improved?

    Read the article

  • How to copy bytes from buffer into the managed struct?

    - by Chupo_cro
    I have a problem with getting the code to work in a managed environment (VS2008 C++/CLI Win Forms App). The problem is I cannot declare the unmanaged struct (is that even possible?) inside the managed code, so I've declared a managed struct but now I have a problem how to copy bytes from buffer into that struct. Here is the pure C++ code that obviously works as expected: typedef struct GPS_point { float point_unknown_1; float latitude; float longitude; float altitude; // x10000 float time; int point_unknown_2; int speed; // x100 int manually_logged_point; // flag (1 --> point logged manually) } track_point; int offset = 0; int filesize = 256; // simulates filesize int point_num = 10; // simulates number of records int main () { char *buffer_dyn = new char[filesize]; // allocate RAM // here, the file would have been read into the buffer buffer_dyn[0xa8] = 0x1e; // simulates the speed data (1e 00 00 00) buffer_dyn[0xa9] = 0x00; buffer_dyn[0xaa] = 0x00; buffer_dyn[0xab] = 0x00; offset = 0x90; // if the data with this offset is transfered trom buffer // to struct, int speed is alligned with the buffer at the // offset of 0xa8 track_point *points = new track_point[point_num]; points[0].speed = 0xff; // (debug) it should change into 0x1e memcpy(&points[0],buffer_dyn+offset,32); cout << "offset: " << offset << "\r\n"; //cout << "speed: " << points[0].speed << "\r\n"; printf ("speed : 0x%x\r\n",points[0].speed); printf("byte at offset 0xa8: 0x%x\r\n",(unsigned char)buffer_dyn[0xa8]); // should be 0x1e delete[] buffer_dyn; // release RAM delete[] points; /* What I need is to rewrite the lines 29 and 31 to work in the managed code (VS2008 Win Forms C++/CLI) What should I have after: array<track_point^>^ points = gcnew array<track_point^>(point_num); so I can copy 32 bytes from buffer_dyn to the managed struct declared as typedef ref struct GPS_point { float point_unknown_1; float latitude; float longitude; float altitude; // x10000 float time; int point_unknown_2; int speed; // x100 int manually_logged_point; // flag (1 --> point logged manually) } track_point; */ return 0; } Here is the paste to codepad.org so it can be seen the code is OK. What I need is to rewrite these two lines: track_point *points = new track_point[point_num]; memcpy(&points[0],buffer_dyn+offset,32); to something that will work in a managed application. I wrote: array<track_point^>^ points = gcnew array<track_point^>(point_num); and now trying to reproduce the described copying of the data from buffer over the struct, but haven't any idea how it should be done. Alternatively, if there is a way to use an unmanaged struct in the same way shown in my code, then I would like to avoid working with managed struct.

    Read the article

  • What is wrong in this c++ code?

    - by narayanpatra
    Why this coder do not show error #include <iostream> int main() { using namespace std; unsigned short int myInt = 99; unsigned short int * pMark = 0; cout << myInt << endl; pMark = &myInt; *pMark = 11; cout << "*pMark:\t" << *pMark << "\nmyInt:\t" << myInt << endl; return 0; } But this one shows : #include<iostream> using namespace std; int addnumber(int *p, int *q){ cout << *p = 12 << endl; cout << *q = 14 << endl; } #include<iostream> using namespace std; int addnumber(int *p, int *q){ cout << *p = 12 << endl; cout << *q = 14 << endl; } int main() { int i , j; cout << "enter the value of first number"; cin >> i; cout << "enter the value of second number"; cin >> j; addnumber(&i, &j); cout << i << endl; cout << j << endl; } In both the code snippets, I am assigning *pointer=somevalue. In first code it do not show any error but it shows error in the line cout << *p = 12 << endl; cout << *q = 14 << endl; What mistake I am doing ?

    Read the article

  • handling large number

    - by klw
    Hello, this is actually an problem question from project euler site http://projecteuler.net/index.php?section=problems&id=3 Anyway I'm not out after the solution, but I probably guess you will know what my approach is. To my question now, how do I handle numbers exceeding unsigned int? Is there a mathematical approach for this, if so where can I read about it?

    Read the article

  • 64 bit enum in C++?

    - by Rob
    Is there a way to have a 64 bit enum in C++? Whilst refactoring some code I came across bunch of #defines which would be better as an enum, but being greater than 32 bit causes the compiler to error. For some reason I thought the following might work: enum MY_ENUM : unsigned __int64 { LARGE_VALUE = 0x1000000000000000, };

    Read the article

  • about getadrrinfo() C++?

    - by Isavel
    I'm reading this book called beej's guide to network programming and there's a part in the book were it provide a sample code which illustrate the use of getaddrinfo(); the book state that the code below "will print the IP addresses for whatever host you specify on the command line" - beej's guide to network programming. now I'm curious and want to try it out and run the code, but I guess the code was develop in UNIX environment and I'm using visual studio 2012 windows 7 OS, and most of the headers was not supported so I did a bit of research and find out that I need to include the winsock.h and ws2_32.lib for windows, for it to get working, fortunately everything compiled no errors, but when I run it using the debugger and put in 'www.google.com' as command argument I was disappointed that it did not print any ipaddress, the output that I got from the console is "getaddrinfo: E" what does the letter E mean? Do I need to configure something out of the debugger? Interestingly I left the command argument blank and the output changed to "usage: showip hostname" Any help would be appreciated. #ifdef _WIN32 #endif #include <sys/types.h> #include <winsock2.h> #include <ws2tcpip.h> #include <iostream> using namespace std; #include <stdio.h> #include <string.h> #include <sys/types.h> #include <winsock.h> #pragma comment(lib, "ws2_32.lib") int main(int argc, char *argv[]) { struct addrinfo hints, *res, *p; int status; char ipstr[INET6_ADDRSTRLEN]; if (argc != 2) { fprintf(stderr,"usage: showip hostname\n"); system("PAUSE"); return 1; } memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version hints.ai_socktype = SOCK_STREAM; if ((status = getaddrinfo(argv[1], NULL, &hints, &res)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status)); system("PAUSE"); return 2; } printf("IP addresses for %s:\n\n", argv[1]); for(p = res;p != NULL; p = p->ai_next) { void *addr; char *ipver; // get the pointer to the address itself, // different fields in IPv4 and IPv6: if (p->ai_family == AF_INET) { // IPv4 struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr; addr = &(ipv4->sin_addr); ipver = "IPv4"; } else { // IPv6 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)p->ai_addr; addr = &(ipv6->sin6_addr); ipver = "IPv6"; } // convert the IP to a string and print it: inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr); printf(" %s: %s\n", ipver, ipstr); } freeaddrinfo(res); // free the linked list system("PAUSE"); return 0; }

    Read the article

  • How to read large number of rows efficiently using Zend_Db?

    - by Alex N.
    Is there a simple :) and efficient way or reading very large number of rows sequentially using Zend_Db? Basically I need to process entire table, row by row. Table is large, primary key sequence is not guaranteed(i.e. not an autoincrement, but is UNSIGNED INT). What's the best way to approach this? Environment: PHP 5.2, Zend Framework 1.10, MySQL 5.1

    Read the article

  • Writting a getter for a pointer to a function .

    - by nomemory
    I have the following problem: "list.c" struct nmlist_element_s { void *data; struct nmlist_element_s *next; }; struct nmlist_s { nmlist_element *head; nmlist_element *tail; unsigned int size; void (*destructor)(void *data); int (*match)(const void *e1, const void *e2); }; /*** Other code ***/ What will be the signature for a function that returns 'destructor' ?

    Read the article

  • Looking for some help working with premultiplied alpha

    - by user315142
    I am trying to update a source image with the contents of multiple destination images. From what I can tell using premultiplied alpha is the way to go with this, but I think I am doing something wrong (function below). the image I am starting with is initialized with all ARGB values set to 0. When I run the function once the resulting image looks great, but when I start compositing on any others all the pixels that have alpha information get really messed up. Does anyone know if I am doing something glaringly wrong or if there is something extra I need to do to modify the color values? void CompositeImage(unsigned char *src, unsigned char *dest, int srcW, int srcH){ int w = srcW; int h = srcH; int px0; int px1; int px2; int px3; int inverseAlpha; int r; int g; int b; int a; int y; int x; for (y = 0; y < h; y++) { for (x= 0; x< w*4; x+=4) { // pixel number px0 = (y*w*4) + x; px1 = (y*w*4) + (x+1); px2 = (y*w*4) + (x+2); px3 = (y*w*4) + (x+3); inverseAlpha = 1 - src[px3]; // create new values r = src[px0] + inverseAlpha * dest[px0]; g = src[px1] + inverseAlpha * dest[px1]; b = src[px2] + inverseAlpha * dest[px2]; a = src[px3] + inverseAlpha * dest[px3]; // update destination image dest[px0] = r; dest[px1] = g; dest[px2] = b; dest[px3] = a; } } }

    Read the article

  • Why is there no Sum() extension for IEnumerable<uint>

    - by dss539
    It seems that Sum not defined for IEnumerable<uint> (and other unsigned integers, for that matter) var s = new int[] { 1, 2, 3 }; s.Sum(); //works fine var us = new uint[] { 1, 2, 3 }; us.Sum(); //missing method I would like to know: Have I done something fundamentally wrong/misunderstood the situation? What design decisions might cause the omission of IEnumerable<uint>.Sum()? MSDN: Enumerable.Sum

    Read the article

  • Auto-Suggest via &lsquo;Trie&rsquo; (Pre-fix Tree)

    - by Strenium
    Auto-Suggest (Auto-Complete) “thing” has been around for a few years. Here’s my little snippet on the subject. For one of my projects, I had to deal with a non-trivial set of items to be pulled via auto-suggest used by multiple concurrent users. Simple, dumb iteration through a list in local cache or back-end access didn’t quite cut it. Enter a nifty little structure, perfectly suited for storing and matching verbal data: “Trie” (http://tinyurl.com/db56g) also known as a Pre-fix Tree: “Unlike a binary search tree, no node in the tree stores the key associated with that node; instead, its position in the tree defines the key with which it is associated. All the descendants of a node have a common prefix of the string associated with that node, and the root is associated with the empty string. Values are normally not associated with every node, only with leaves and some inner nodes that correspond to keys of interest.” This is a very scalable, performing structure. Though, as usual, something ‘fast’ comes at a cost of ‘size’; fortunately RAM is more plentiful today so I can live with that. I won’t bore you with the detailed algorithmic performance here - Google can do a better job of such. So, here’s C# implementation of all this. Let’s start with individual node: Trie Node /// <summary> /// Contains datum of a single trie node. /// </summary> public class AutoSuggestTrieNode {     public char Value { get; set; }       /// <summary>     /// Gets a value indicating whether this instance is leaf node.     /// </summary>     /// <value>     ///     <c>true</c> if this instance is leaf node; otherwise, a prefix node <c>false</c>.     /// </value>     public bool IsLeafNode { get; private set; }       public List<AutoSuggestTrieNode> DescendantNodes { get; private set; }         /// <summary>     /// Initializes a new instance of the <see cref="AutoSuggestTrieNode"/> class.     /// </summary>     /// <param name="value">The phonetic value.</param>     /// <param name="isLeafNode">if set to <c>true</c> [is leaf node].</param>     public AutoSuggestTrieNode(char value = ' ', bool isLeafNode = false)     {         Value = value;         IsLeafNode = isLeafNode;           DescendantNodes = new List<AutoSuggestTrieNode>();     }       /// <summary>     /// Gets the descendants of the pre-fix node, if any.     /// </summary>     /// <param name="descendantValue">The descendant value.</param>     /// <returns></returns>     public AutoSuggestTrieNode GetDescendant(char descendantValue)     {         return DescendantNodes.FirstOrDefault(descendant => descendant.Value == descendantValue);     } }   Quite self-explanatory, imho. A node is either a “Pre-fix” or a “Leaf” node. “Leaf” contains the full “word”, while the “Pre-fix” nodes act as indices used for matching the results.   Ok, now the Trie: Trie Structure /// <summary> /// Contains structure and functionality of an AutoSuggest Trie (Pre-fix Tree) /// </summary> public class AutoSuggestTrie {     private readonly AutoSuggestTrieNode _root = new AutoSuggestTrieNode();       /// <summary>     /// Adds the word to the trie by breaking it up to pre-fix nodes + leaf node.     /// </summary>     /// <param name="word">Phonetic value.</param>     public void AddWord(string word)     {         var currentNode = _root;         word = word.Trim().ToLower();           for (int i = 0; i < word.Length; i++)         {             var child = currentNode.GetDescendant(word[i]);               if (child == null) /* this character hasn't yet been indexed in the trie */             {                 var newNode = new AutoSuggestTrieNode(word[i], word.Count() - 1 == i);                   currentNode.DescendantNodes.Add(newNode);                 currentNode = newNode;             }             else                 currentNode = child; /* this character is already indexed, move down the trie */         }     }         /// <summary>     /// Gets the suggested matches.     /// </summary>     /// <param name="word">The phonetic search value.</param>     /// <returns></returns>     public List<string> GetSuggestedMatches(string word)     {         var currentNode = _root;         word = word.Trim().ToLower();           var indexedNodesValues = new StringBuilder();         var resultBag = new ConcurrentBag<string>();           for (int i = 0; i < word.Trim().Length; i++)  /* traverse the trie collecting closest indexed parent (parent can't be leaf, obviously) */         {             var child = currentNode.GetDescendant(word[i]);               if (child == null || word.Count() - 1 == i)                 break; /* done looking, the rest of the characters aren't indexed in the trie */               indexedNodesValues.Append(word[i]);             currentNode = child;         }           Action<AutoSuggestTrieNode, string> collectAllMatches = null;         collectAllMatches = (node, aggregatedValue) => /* traverse the trie collecting matching leafNodes (i.e. "full words") */             {                 if (node.IsLeafNode) /* full word */                     resultBag.Add(aggregatedValue); /* thread-safe write */                   Parallel.ForEach(node.DescendantNodes, descendandNode => /* asynchronous recursive traversal */                 {                     collectAllMatches(descendandNode, String.Format("{0}{1}", aggregatedValue, descendandNode.Value));                 });             };           collectAllMatches(currentNode, indexedNodesValues.ToString());           return resultBag.OrderBy(o => o).ToList();     }         /// <summary>     /// Gets the total words (leafs) in the trie. Recursive traversal.     /// </summary>     public int TotalWords     {         get         {             int runningCount = 0;               Action<AutoSuggestTrieNode> traverseAllDecendants = null;             traverseAllDecendants = n => { runningCount += n.DescendantNodes.Count(o => o.IsLeafNode); n.DescendantNodes.ForEach(traverseAllDecendants); };             traverseAllDecendants(this._root);               return runningCount;         }     } }   Matching operations and Inserts involve traversing the nodes before the right “spot” is found. Inserts need be synchronous since ordering of data matters here. However, matching can be done in parallel traversal using recursion (line 64). Here’s sample usage:   [TestMethod] public void AutoSuggestTest() {     var autoSuggestCache = new AutoSuggestTrie();       var testInput = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero.                 Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris.                 Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad                 litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc.                 Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem.                 Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac                 turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque                 volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam                 nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla                 facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam                 ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus                 vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci                 luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet                 augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec.";       testInput.Split(' ').ToList().ForEach(word => autoSuggestCache.AddWord(word));       var testMatches = autoSuggestCache.GetSuggestedMatches("le"); }   ..and the result: That’s it!

    Read the article

  • Operator of the week - Assert

    - by Fabiano Amorim
    Well my friends, I was wondering how to help you in a practical way to understand execution plans. So I think I'll talk about the Showplan Operators. Showplan Operators are used by the Query Optimizer (QO) to build the query plan in order to perform a specified operation. A query plan will consist of many physical operators. The Query Optimizer uses a simple language that represents each physical operation by an operator, and each operator is represented in the graphical execution plan by an icon. I'll try to talk about one operator every week, but so as to avoid having to continue to write about these operators for years, I'll mention only of those that are more common: The first being the Assert. The Assert is used to verify a certain condition, it validates a Constraint on every row to ensure that the condition was met. If, for example, our DDL includes a check constraint which specifies only two valid values for a column, the Assert will, for every row, validate the value passed to the column to ensure that input is consistent with the check constraint. Assert  and Check Constraints: Let's see where the SQL Server uses that information in practice. Take the following T-SQL: IF OBJECT_ID('Tab1') IS NOT NULL   DROP TABLE Tab1 GO CREATE TABLE Tab1(ID Integer, Gender CHAR(1))  GO  ALTER TABLE TAB1 ADD CONSTRAINT ck_Gender_M_F CHECK(Gender IN('M','F'))  GO INSERT INTO Tab1(ID, Gender) VALUES(1,'X') GO To the command above the SQL Server has generated the following execution plan: As we can see, the execution plan uses the Assert operator to check that the inserted value doesn't violate the Check Constraint. In this specific case, the Assert applies the rule, 'if the value is different to "F" and different to "M" than return 0 otherwise returns NULL'. The Assert operator is programmed to show an error if the returned value is not NULL; in other words, the returned value is not a "M" or "F". Assert checking Foreign Keys Now let's take a look at an example where the Assert is used to validate a foreign key constraint. Suppose we have this  query: ALTER TABLE Tab1 ADD ID_Genders INT GO  IF OBJECT_ID('Tab2') IS NOT NULL   DROP TABLE Tab2 GO CREATE TABLE Tab2(ID Integer PRIMARY KEY, Gender CHAR(1))  GO  INSERT INTO Tab2(ID, Gender) VALUES(1, 'F') INSERT INTO Tab2(ID, Gender) VALUES(2, 'M') INSERT INTO Tab2(ID, Gender) VALUES(3, 'N') GO  ALTER TABLE Tab1 ADD CONSTRAINT fk_Tab2 FOREIGN KEY (ID_Genders) REFERENCES Tab2(ID) GO  INSERT INTO Tab1(ID, ID_Genders, Gender) VALUES(1, 4, 'X') Let's look at the text execution plan to see what these Assert operators were doing. To see the text execution plan just execute SET SHOWPLAN_TEXT ON before run the insert command. |--Assert(WHERE:(CASE WHEN NOT [Pass1008] AND [Expr1007] IS NULL THEN (0) ELSE NULL END))      |--Nested Loops(Left Semi Join, PASSTHRU:([Tab1].[ID_Genders] IS NULL), OUTER REFERENCES:([Tab1].[ID_Genders]), DEFINE:([Expr1007] = [PROBE VALUE]))           |--Assert(WHERE:(CASE WHEN [Tab1].[Gender]<>'F' AND [Tab1].[Gender]<>'M' THEN (0) ELSE NULL END))           |    |--Clustered Index Insert(OBJECT:([Tab1].[PK]), SET:([Tab1].[ID] = RaiseIfNullInsert([@1]),[Tab1].[ID_Genders] = [@2],[Tab1].[Gender] = [Expr1003]), DEFINE:([Expr1003]=CONVERT_IMPLICIT(char(1),[@3],0)))           |--Clustered Index Seek(OBJECT:([Tab2].[PK]), SEEK:([Tab2].[ID]=[Tab1].[ID_Genders]) ORDERED FORWARD) Here we can see the Assert operator twice, first (looking down to up in the text plan and the right to left in the graphical plan) validating the Check Constraint. The same concept showed above is used, if the exit value is "0" than keep running the query, but if NULL is returned shows an exception. The second Assert is validating the result of the Tab1 and Tab2 join. It is interesting to see the "[Expr1007] IS NULL". To understand that you need to know what this Expr1007 is, look at the Probe Value (green text) in the text plan and you will see that it is the result of the join. If the value passed to the INSERT at the column ID_Gender exists in the table Tab2, then that probe will return the join value; otherwise it will return NULL. So the Assert is checking the value of the search at the Tab2; if the value that is passed to the INSERT is not found  then Assert will show one exception. If the value passed to the column ID_Genders is NULL than the SQL can't show a exception, in that case it returns "0" and keeps running the query. If you run the INSERT above, the SQL will show an exception because of the "X" value, but if you change the "X" to "F" and run again, it will show an exception because of the value "4". If you change the value "4" to NULL, 1, 2 or 3 the insert will be executed without any error. Assert checking a SubQuery: The Assert operator is also used to check one subquery. As we know, one scalar subquery can't validly return more than one value: Sometimes, however, a  mistake happens, and a subquery attempts to return more than one value . Here the Assert comes into play by validating the condition that a scalar subquery returns just one value. Take the following query: INSERT INTO Tab1(ID_TipoSexo, Sexo) VALUES((SELECT ID_TipoSexo FROM Tab1), 'F')    INSERT INTO Tab1(ID_TipoSexo, Sexo) VALUES((SELECT ID_TipoSexo FROM Tab1), 'F')    |--Assert(WHERE:(CASE WHEN NOT [Pass1016] AND [Expr1015] IS NULL THEN (0) ELSE NULL END))        |--Nested Loops(Left Semi Join, PASSTHRU:([tempdb].[dbo].[Tab1].[ID_TipoSexo] IS NULL), OUTER REFERENCES:([tempdb].[dbo].[Tab1].[ID_TipoSexo]), DEFINE:([Expr1015] = [PROBE VALUE]))              |--Assert(WHERE:([Expr1017]))             |    |--Compute Scalar(DEFINE:([Expr1017]=CASE WHEN [tempdb].[dbo].[Tab1].[Sexo]<>'F' AND [tempdb].[dbo].[Tab1].[Sexo]<>'M' THEN (0) ELSE NULL END))              |         |--Clustered Index Insert(OBJECT:([tempdb].[dbo].[Tab1].[PK__Tab1__3214EC277097A3C8]), SET:([tempdb].[dbo].[Tab1].[ID_TipoSexo] = [Expr1008],[tempdb].[dbo].[Tab1].[Sexo] = [Expr1009],[tempdb].[dbo].[Tab1].[ID] = [Expr1003]))              |              |--Top(TOP EXPRESSION:((1)))              |                   |--Compute Scalar(DEFINE:([Expr1008]=[Expr1014], [Expr1009]='F'))              |                        |--Nested Loops(Left Outer Join)              |                             |--Compute Scalar(DEFINE:([Expr1003]=getidentity((1856985942),(2),NULL)))              |                             |    |--Constant Scan              |                             |--Assert(WHERE:(CASE WHEN [Expr1013]>(1) THEN (0) ELSE NULL END))              |                                  |--Stream Aggregate(DEFINE:([Expr1013]=Count(*), [Expr1014]=ANY([tempdb].[dbo].[Tab1].[ID_TipoSexo])))             |                                       |--Clustered Index Scan(OBJECT:([tempdb].[dbo].[Tab1].[PK__Tab1__3214EC277097A3C8]))              |--Clustered Index Seek(OBJECT:([tempdb].[dbo].[Tab2].[PK__Tab2__3214EC27755C58E5]), SEEK:([tempdb].[dbo].[Tab2].[ID]=[tempdb].[dbo].[Tab1].[ID_TipoSexo]) ORDERED FORWARD)  You can see from this text showplan that SQL Server as generated a Stream Aggregate to count how many rows the SubQuery will return, This value is then passed to the Assert which then does its job by checking its validity. Is very interesting to see that  the Query Optimizer is smart enough be able to avoid using assert operators when they are not necessary. For instance: INSERT INTO Tab1(ID_TipoSexo, Sexo) VALUES((SELECT ID_TipoSexo FROM Tab1 WHERE ID = 1), 'F') INSERT INTO Tab1(ID_TipoSexo, Sexo) VALUES((SELECT TOP 1 ID_TipoSexo FROM Tab1), 'F')  For both these INSERTs, the Query Optimiser is smart enough to know that only one row will ever be returned, so there is no need to use the Assert. Well, that's all folks, I see you next week with more "Operators". Cheers, Fabiano

    Read the article

  • Macbook OSX applications crashing on startup

    - by Ryan Doom
    Closed my computer last night, went home. Opened it and it had restarted. Now when I open a couple programs such as Adobe Fireworks or Appcelerator Titanium they throw up a nasty error like below. Other programs (Chrome, Firefox, Textmate, Versions) works fine. Any thoughts on this? I haven't owned my Macbook long so I'm not even aware of the right tools or places to look to track this down. Any help would be most appreciated. It's making it hard to get my work done :] If it helps at all both those programs were probably open when it restarted. From the look of it I'm not sure if it's a permissions error or something? I completely re-installed on of the applications Titanium. Didn't seem to help. Process: Adobe Fireworks CS5 [1044] Path: /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/MacOS/Adobe Fireworks CS5 Identifier: com.macromedia.fireworks Version: Adobe Fireworks CS5 version 11.0.0.484 (11.0.0) Code Type: X86 (Native) Parent Process: launchd [87] Date/Time: 2011-02-18 09:45:47.689 -0500 OS Version: Mac OS X 10.6.6 (10J567) Report Version: 6 Interval Since Last Report: 12983 sec Crashes Since Last Report: 6 Per-App Interval Since Last Report: 325365 sec Per-App Crashes Since Last Report: 4 Anonymous UUID: D16EAFE7-2F04-44D4-A984-5902A6EF8943 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000b0327ff8 Crashed Thread: 7 Thread 0: Dispatch queue: com.apple.main-thread 0 libSystem.B.dylib 0x97dd0142 semaphore_wait_signal_trap + 10 1 libSystem.B.dylib 0x97dd5c46 pthread_mutex_lock + 490 2 libstdc++.6.dylib 0x91887559 __gnu_cxx::__recursive_mutex::lock() + 17 3 libstdc++.6.dylib 0x918874e6 __cxa_guard_acquire + 68 4 libTrueTypeScaler.dylib 0x91c92ab3 TTScalerInfo() + 50 5 libFontParser.dylib 0x9979a5f1 TTrueTypeScaler::CreateTrueTypeScaler() + 43 6 libSystem.B.dylib 0x97dee900 pthread_once + 82 7 libFontParser.dylib 0x9979a575 TTrueTypeScaler::GetTrueTypeScaler() + 47 8 libFontParser.dylib 0x9979a520 TTrueTypeScaler::TTrueTypeScaler(TScalerStrike const&) + 26 9 libFontParser.dylib 0x9979a4be TFontScaler::CreateFontScaler(TScalerStrike const&) + 52 10 libFontParser.dylib 0x9979bd93 FPFontGetGlyphsForUnichars + 344 11 com.apple.CoreText 0x98255cfe TBaseFont::CalculateFontMetrics(bool) const + 342 12 com.apple.CoreText 0x98255b55 TBaseFont::InitFontMetrics() const + 51 13 com.apple.CoreText 0x98255959 TBaseFont::GetStrikeMetrics(float, CGAffineTransform const*, bool) const + 81 14 com.apple.CoreText 0x982558cd TFont::InitStrikeMetrics() const + 55 15 com.apple.CoreText 0x982592cf CTFontGetAscent + 49 16 com.apple.AppKit 0x989f5d08 _NSFontInstanceInfoInitializeMetricsInfo + 48 17 com.apple.AppKit 0x989f5cbc -[_NSSharedFontInstanceInfo _defaultLineHeight:] + 40 18 com.apple.AppKit 0x98f3c5e8 +[NSStringDrawingTextStorage _fastDrawString:attributes:length:inRect:graphicsContext:baselineRendering:usesFontLeading:usesScreenFont:typesetterBehavior:paragraphStyle:lineBreakMode:boundingRect:padding:scrollable:] + 2041 19 com.apple.AppKit 0x98abd2d9 _NSStringDrawingCore + 1555 20 com.apple.AppKit 0x98abca8b _NSDrawTextCell + 3465 21 com.apple.AppKit 0x98ac6185 -[NSTextFieldCell drawInteriorWithFrame:inView:] + 764 22 com.apple.AppKit 0x98ac5d26 -[NSTextFieldCell drawWithFrame:inView:] + 816 23 com.apple.AppKit 0x98ac03de -[NSControl drawRect:] + 589 24 com.apple.AppKit 0x98ab882a -[NSView _drawRect:clip:] + 3510 25 com.apple.AppKit 0x98ab74c8 -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1600 26 com.apple.AppKit 0x98ab77fd -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2421 27 com.apple.AppKit 0x98ab77fd -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2421 28 com.apple.AppKit 0x98ab59e7 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 711 29 com.apple.AppKit 0x98b54aa3 -[NSNextStepFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 311 30 com.apple.AppKit 0x98ab1ea2 -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 3309 31 com.apple.AppKit 0x98a12a57 -[NSView displayIfNeeded] + 818 32 com.apple.AppKit 0x989c6661 -[NSNextStepFrame displayIfNeeded] + 98 33 com.apple.AppKit 0x98b55390 -[NSWindow display] + 75 34 com.macromedia.fireworks 0x00bade98 0x1000 + 12242584 35 com.macromedia.fireworks 0x0089f778 0x1000 + 9037688 36 libPowerPlant2.dylib 0x08109722 FW_PowerPlant::LCarbonApp::Run() + 54 37 com.macromedia.fireworks 0x008a138c 0x1000 + 9044876 38 com.macromedia.fireworks 0x00003596 0x1000 + 9622 Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x97df6982 kevent + 10 1 libSystem.B.dylib 0x97df709c _dispatch_mgr_invoke + 215 2 libSystem.B.dylib 0x97df6559 _dispatch_queue_invoke + 163 3 libSystem.B.dylib 0x97df62fe _dispatch_worker_thread2 + 240 4 libSystem.B.dylib 0x97df5d81 _pthread_wqthread + 390 5 libSystem.B.dylib 0x97df5bc6 start_wqthread + 30 Thread 2: 0 libSystem.B.dylib 0x97df5a12 __workq_kernreturn + 10 1 libSystem.B.dylib 0x97df5fa8 _pthread_wqthread + 941 2 libSystem.B.dylib 0x97df5bc6 start_wqthread + 30 Thread 3: 0 libSystem.B.dylib 0x97dd015a semaphore_timedwait_signal_trap + 10 1 libSystem.B.dylib 0x97dfdce5 _pthread_cond_wait + 1066 2 libSystem.B.dylib 0x97e2cac8 pthread_cond_timedwait_relative_np + 47 3 ...ple.CoreServices.CarbonCore 0x97af4ecd TSWaitOnConditionTimedRelative + 242 4 ...ple.CoreServices.CarbonCore 0x97af4c0b TSWaitOnSemaphoreCommon + 511 5 ...ple.CoreServices.CarbonCore 0x97b18e33 TimerThread + 97 6 libSystem.B.dylib 0x97dfd85d _pthread_start + 345 7 libSystem.B.dylib 0x97dfd6e2 thread_start + 34 Thread 4: 0 libSystem.B.dylib 0x97dd00fa mach_msg_trap + 10 1 libSystem.B.dylib 0x97dd0867 mach_msg + 68 2 ...ple.CoreServices.CarbonCore 0x97b9e0d0 YieldToThread + 446 3 ...ple.CoreServices.CarbonCore 0x97b9e1d3 SetThreadState + 134 4 ...ple.CoreServices.CarbonCore 0x97b9e28e SetThreadStateEndCritical + 111 5 libPowerPlant2.dylib 0x0811ab51 FW_PowerPlant::LThread::SemWait(FW_PowerPlant::LSemaphore*, long, QHdr&, unsigned char&) + 119 6 libPowerPlant2.dylib 0x08119b07 FW_PowerPlant::LSemaphore::BlockThread(long) + 61 7 libPowerPlant2.dylib 0x08119b6d FW_PowerPlant::LSemaphore::Wait(long) + 71 8 libPowerPlant2.dylib 0x0811af70 FW_PowerPlant::LThread::Cleanup::Run() + 32 9 libPowerPlant2.dylib 0x0811b94e FW_PowerPlant::LThread::DoEntry(void*) + 30 10 ...ple.CoreServices.CarbonCore 0x97b9e85f CooperativeThread + 309 11 libSystem.B.dylib 0x97dfd85d _pthread_start + 345 12 libSystem.B.dylib 0x97dfd6e2 thread_start + 34 Thread 5: 0 libSystem.B.dylib 0x97dd0142 semaphore_wait_signal_trap + 10 1 libSystem.B.dylib 0x97dfdcfc _pthread_cond_wait + 1089 2 libSystem.B.dylib 0x97e4646f pthread_cond_wait + 48 3 com.adobe.amt.services 0x1dd73126 AMTConditionLock::LockWhenCondition(int) + 46 4 com.adobe.amt.services 0x1dd6bdb0 _AMTThreadedPCDService::PCDThreadWorker(_AMTThreadedPCDService*) + 116 5 com.adobe.amt.services 0x1dd7318c AMTThread::Worker(void*) + 24 6 libSystem.B.dylib 0x97dfd85d _pthread_start + 345 7 libSystem.B.dylib 0x97dfd6e2 thread_start + 34 Thread 6: 0 libSystem.B.dylib 0x97dfe0a6 __semwait_signal + 10 1 libSystem.B.dylib 0x97dfdd62 _pthread_cond_wait + 1191 2 libSystem.B.dylib 0x97dff9f8 pthread_cond_wait$UNIX2003 + 73 3 ...ple.CoreServices.CarbonCore 0x97b0951e TSWaitOnCondition + 126 4 ...ple.CoreServices.CarbonCore 0x97af4ea5 TSWaitOnConditionTimedRelative + 202 5 ...ple.CoreServices.CarbonCore 0x97af0873 MPWaitOnQueue + 250 6 com.macromedia.fireworks 0x00ae43cf 0x1000 + 11416527 7 ...ple.CoreServices.CarbonCore 0x97ad485a PrivateMPEntryPoint + 68 8 libSystem.B.dylib 0x97dfd85d _pthread_start + 345 9 libSystem.B.dylib 0x97dfd6e2 thread_start + 34 Thread 7 Crashed: 0 libstdc++.6.dylib 0x9184e00c std::basic_ofstream ::open(char const*, std::_Ios_Openmode) + 16 1 libstdc++.6.dylib 0x9184fe9b std::basic_ifstream ::basic_ifstream(char const*, std::_Ios_Openmode) + 211 2 ...pdaterNotificationFramework 0x1e824779 ESDifstream::ESDifstream(std::string const&, char const*, std::_Ios_Openmode) + 73 3 ...pdaterNotificationFramework 0x1e821b6a esd::ExpatDOMBuilder::ParseFile(std::string const&, bool) + 96 4 ...pdaterNotificationFramework 0x1e822da4 esd::PrefsWriter::SetPrefsPath(std::string const&) + 206 5 ...pdaterNotificationFramework 0x1e8449b3 AdobeUpdaterPrefs::AdobeUpdaterPrefs() + 8609 6 ...pdaterNotificationFramework 0x1e8459f4 AdobeUpdaterPrefs::GetAdobeUpdaterPrefs() + 68 7 ...pdaterNotificationFramework 0x1e820728 UpdaterNotificationsImpl::InitLogFile() + 48 8 ...pdaterNotificationFramework 0x1e820d49 UpdaterNotificationsImpl::Instance() + 53 9 ...pdaterNotificationFramework 0x1e823638 UpdaterNotificationsIsUpdaterEnabled + 22 10 com.adobe.amt.services 0x1dd69d15 _AMTAUMService::IsUpdaterEnabled(T_CSUStatusMajor*, int*) + 359 11 com.adobe.amtlib 0x01f5501c AMTAUMServiceIsUpdaterEnabled + 290 12 com.adobe.amtlib 0x01f1f789 AMTImpl::CallMenuEnablers() + 71 13 com.adobe.amtlib 0x01f260fa AMTImpl::DoLaunchWorkflow(AMTImpl::LaunchSequence) + 1664 14 com.adobe.amtlib 0x01f26a5d AMTImpl::DoValidateWorkflow(AMTImpl::LaunchSequence) + 293 15 com.adobe.amtlib 0x01f26cf5 AMTImpl::DoPreValidateWorkflow() + 119 16 com.adobe.amtlib 0x01f26e71 AMTImpl::ServiceLoaderThread(void*) + 45 17 com.adobe.amtlib 0x01f54c48 AMTThread::Worker(void*) + 24 18 libSystem.B.dylib 0x97dfd85d _pthread_start + 345 19 libSystem.B.dylib 0x97dfd6e2 thread_start + 34 Thread 7 crashed with X86 Thread State (32-bit): eax: 0x00000016 ebx: 0x098c9a00 ecx: 0xa013dfc0 edx: 0x00000003 edi: 0x098c9a08 esi: 0x098c9c0c ebp: 0xb03a7448 esp: 0xb0327ff0 ss: 0x0000001f efl: 0x00010202 eip: 0x9184e00c cs: 0x00000017 ds: 0x0000001f es: 0x0000001f fs: 0x0000001f gs: 0x00000037 cr2: 0xb0327ff8 Binary Images: 0x1000 - 0x1448ff1 +com.macromedia.fireworks Adobe Fireworks CS5 version 11.0.0.484 (11.0.0) <38213EBD-FDB0-FC20-40E8-87935A5386BB /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/MacOS/Adobe Fireworks CS5 0x1e76000 - 0x1ec9ffb +com.adobe.headlights.LogSessionFramework ??? (2.0.1.011) <4F2BFF03-01D2-A07D-E5E2-7F88D4C2DEC4 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/LogSession.framework/Versions/A/LogSession 0x1f11000 - 0x1f77ffb +com.adobe.amtlib amtlib 3.0.0.64 (3.0.0.64) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/amtlib.framework/Versions/A/amtlib 0x1fa7000 - 0x2146fe7 +com.adobe.owl AdobeOwl version 3.0.81 (3.0.81) <9C261D9E-9BD7-5DE6-5676-AEEF4828D17B /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeOwl.framework/Versions/A/AdobeOwl 0x21af000 - 0x22e7fe7 +WRServices ??? (???) <52CE5B97-1E6A-92A2-EA70-93511AB7EA2E /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/WRServices.framework/Versions/A/WRServices 0x232d000 - 0x239afef +FileInfo ??? (???) <4A4C74F9-CA83-B174-F56D-F7671DC61389 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/FileInfo.framework/Versions/A/FileInfo 0x23b5000 - 0x23dbff6 +AdobeAXE8SharedExpat ??? (???) <5848BBCE-3A3E-66EE-5527-97A96F0CA4CC /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeAXE8SharedExpat.framework/Versions/A/AdobeAXE8SharedExpat 0x23ec000 - 0x2407fff +AdobeBIB ??? (???) <3B3092DC-A296-9D1C-1922-D20E6A5A7D7E /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeBIB.framework/Versions/A/AdobeBIB 0x2411000 - 0x2469ff7 +AdobeXMP ??? (???) <73329999-C364-2451-6574-4D0277057D19 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeXMP.framework/Versions/A/AdobeXMP 0x2478000 - 0x2aa6fe7 +AdobeAGM ??? (???) <91D37E54-E985-47E1-2696-0BD7E4183132 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeAGM.framework/Versions/A/AdobeAGM 0x2c04000 - 0x2d18fff +AdobeACE ??? (???) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeACE.framework/Versions/A/AdobeACE 0x2d3b000 - 0x302dff7 +AdobeCoolType ??? (???) <9FDD596D-9824-2BB9-5DA2-25DACAB6A324 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeCoolType.framework/Versions/A/AdobeCoolType 0x30b5000 - 0x30d6ff7 +AdobeBIBUtils ??? (???) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeBIBUtils.framework/Versions/A/AdobeBIBUtils 0x30e2000 - 0x311efff +AdobeARE ??? (???) <76851E91-2381-5D05-742C-BB24E4BAD276 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeARE.framework/Versions/A/AdobeARE 0x3127000 - 0x34ffff7 +AdobeMPS ??? (???) <13614867-4D80-EB74-FA7F-6136492478BA /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeMPS.framework/Versions/A/AdobeMPS 0x362e000 - 0x3c62feb +AdobePDFL ??? (???) <49D6D58A-1EBB-424A-4CB0-8F9691E0991D /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobePDFL.framework/Versions/A/AdobePDFL 0x3d8e000 - 0x4ad1fff +com.adobe.psl AdobePSL 12.0.0.7524 (12.0.0.7524) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobePSL.framework/Versions/A/AdobePSL 0x4e10000 - 0x4e9aff7 +com.adobe.AdobeScCore ScCore 4.1.7 (4.1.7.5522) <053A109E-3E3E-D3EE-7186-4920D927D2AD /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeScCore.framework/Versions/A/AdobeScCore 0x4edd000 - 0x4fc0fef +AdobePDFPort ??? (???) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobePDFPort.framework/Versions/A/AdobePDFPort 0x4ff5000 - 0x4ff8ff8 +com.adobe.ape.shim adbeape version 3.1.65.7508 (3.1.65.7508) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/adbeape.framework/Versions/A/adbeape 0x4ffe000 - 0x508fff7 +libicucnv.dylib.36.0 36.0.0 (compatibility 36.0.0) <581475CC-C039-1B42-49BA-71811D8B4E15 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/ICUConverter.framework/Versions/3.6/libicucnv.dylib.36.0 0x50ae000 - 0x5a5efff +libicudata.dylib.36.0 36.0.0 (compatibility 36.0.0) <02108DEA-3DD2-14BE-DAEB-BE522B619C1D /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/ICUData.framework/Versions/3.6/libicudata.dylib.36.0 0x5a61000 - 0x5b2eff3 +libicui18n.dylib.36.0 36.0.0 (compatibility 36.0.0) <08F15219-7F35-574E-7725-1ACAA1B18A00 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/ICUInternationalization.framework/Versions/3.6/libicui18n.dylib.36.0 0x5b91000 - 0x5c6bfef +libicuuc.dylib.36.0 36.0.0 (compatibility 36.0.0) <5EE72009-40B3-7FB7-3A49-576AEDE0D400 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/ICUUnicode.framework/Versions/3.6/libicuuc.dylib.36.0 0x5cab000 - 0x6a36fe7 +com.adobe.illustrator 382 (15.0.0) <64F68532-0311-6BBA-1F50-246CAF917549 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AILib.framework/Versions/A/AILib 0x781b000 - 0x785ffff +com.adobe.illustrator.aiport AIPort version 1.0 (1.0) <69EDC44E-D7BB-A259-282D-C42725AE0E26 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AIPort.framework/Versions/A/AIPort 0x78c2000 - 0x7908fff +FilterPort ??? (???) <23FAE9D1-9376-1E71-21F7-D3EB2BFD50EE /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/FilterPort.framework/Versions/A/FilterPort 0x797d000 - 0x797dfff +SPBasic ??? (???) <5D1760D8-C910-C641-0BC9-CF74A1A5190D /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/SPBasic.framework/Versions/A/SPBasic 0x7981000 - 0x7b67ff7 +com.adobe.linguistic.LinguisticManager 5.0.0 (11309) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeLinguistic.framework/Versions/3/AdobeLinguistic 0x7bf5000 - 0x7cc2fe7 +AdobeAXEDOMCore ??? (???) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeAXEDOMCore.framework/Versions/A/AdobeAXEDOMCore 0x7d31000 - 0x7ea9ffb +com.adobe.PlugPlug 2.0.0.746 (2.0.0.746) <08AD22E3-34C0-6749-E497-616C66A246AD /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/PlugPlug.framework/Versions/A/PlugPlug 0x7f4d000 - 0x7f6afef +libCurl.dylib ??? (???) <1BA6E2DE-EF14-D50A-4697-035AE07875D7 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/MacOS/libCurl.dylib 0x7f72000 - 0x7f88ff4 +libChar16.dylib ??? (???) <19B0479C-72B1-EE14-6385-7F655DEC0F02 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/MacOS/libChar16.dylib 0x7f90000 - 0x7fb3fe0 +libCoreTypes.dylib ??? (???) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/MacOS/libCoreTypes.dylib 0x7fc3000 - 0x7fcaffc com.apple.carbonframeworktemplate 1.0 (1.0) <0D270CC7-B715-943E-2B4F-5C9B5775505A /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/NetIO.framework/Versions/A/NetIO 0x7fd6000 - 0x7fd9fff +Dioxide.dylib ??? (???) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/Dioxide.dylib 0x7fe1000 - 0x7fe7ffc +libfwutility.dylib ??? (???) <6A723D9E-A60B-56EE-2B8D-B91991793749 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/libfwutility.dylib 0x7fee000 - 0x803efff +com.macromedia.javascript Javascript version 1.0 (1.0) <540CB029-3946-8E41-BD91-AED6F73C86B7 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/Javascript.framework/Versions/A/Javascript 0x8053000 - 0x8060fff +com.macromedia.moa Moa version 1.0 (1.0) <3C4B7F42-5A5D-78E7-B1DC-DAA06A99CCB2 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/Moa.framework/Versions/A/Moa 0x8069000 - 0x8070fff +com.macromedia.morefiles MoreFiles version 1.0 (1.0) <36115C66-79A3-5DB9-B36B-8D655B46FC76 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/MoreFiles.framework/Versions/A/MoreFiles 0x8077000 - 0x815bfe3 +libPowerPlant2.dylib ??? (???) <964FB3D7-B7EE-94EB-FD95-4AE90C657A4A /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/libPowerPlant2.dylib 0x828e000 - 0x8294ffb +com.macromedia.testframework 1.0 (1.0) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/uwchar.framework/Versions/A/uwchar 0x8298000 - 0x829cffc +com.adobe.AdobeCrashReporter 3.0 (3.0.20100302) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeCrashReporter.framework/Versions/A/AdobeCrashReporter 0x82a3000 - 0x82bbfef +libgiff.dylib ??? (???) <8F90552B-3D11-2B1E-D1BA-A109FEB99969 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/libgiff.dylib 0x82c3000 - 0x82e1fe7 +com.macromedia.png LibPNG version 1.0 (1.0) <2DBA0A3F-4F01-7474-0FED-3021382D635F /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/LibPNG.framework/Versions/A/LibPNG 0x82e9000 - 0x82f7feb +com.macromedia.zlib ZLib version 1.0 (1.0) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/ZLib.framework/Versions/A/ZLib 0x82fc000 - 0x8300ffd +com.yourcompany.yourcocoaframework ??? (1.0) <7EF7A82E-0AAE-0022-3B15-7C50F1C550C1 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/ASEFramework.framework/Versions/A/ASEFramework 0x8305000 - 0x830cff2 +com.adobe.boost_threads.framework boost_threads version 5.0.0 (5.0.0.0) /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/boost_threads.framework/Versions/A/boost_threads 0x831c000 - 0x8322fef +com.adobe.boost_date_time.framework boost_date_time version 5.0.0 (5.0.0.0) <8837A972-1EBE-CAA9-473A-CD157F17163D /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/boost_date_time.framework/Versions/A/boost_date_time 0x8333000 - 0x83b0fff +AdobeOwlCanvas ??? (???) <65B2E680-4F43-BE46-2290-3500758D1BF7 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/AdobeOwlCanvas.framework/Versions/A/AdobeOwlCanvas 0x83cc000 - 0x83d7ff3 +com.adobe.boost_filesystem.framework boost_filesystem version 5.0.0 (5.0.0.0) <90B8B4E3-6C44-D110-1545-1A34EB14B22D /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/boost_filesystem.framework/Versions/A/boost_filesystem 0x83eb000 - 0x83edffb +com.adobe.boost_system.framework boost_system version 5.0.0 (5.0.0.0) <0C4D56E8-9593-4C4A-4A7E-BEAEDE1CA131 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/boost_system.framework/Versions/A/boost_system ... E86745B94A4B /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib 0x9984a000 - 0x9989aff7 com.apple.framework.familycontrols 2.0.2 (2020) /System/Library/PrivateFrameworks/FamilyControls.framework/Versions/A/FamilyControls 0x99a6e000 - 0x99a6fff7 com.apple.audio.units.AudioUnit 1.6.5 (1.6.5) /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit 0x99a72000 - 0x99a86ffb com.apple.speech.synthesis.framework 3.10.35 (3.10.35) <9F5CE4F7-D05C-8C14-4B76-E43D07A8A680 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis 0xb0000000 - 0xb000fff8 +com.adobe.ahclientframework 1.5.0.30 (1.5.0.30) <24B39C2F-79B0-BDE3-C6D0-1F0E943070C7 /Applications/Adobe Fireworks CS5/Adobe Fireworks CS5.app/Contents/Frameworks/ahclient.framework/Versions/A/ahclient 0xffff0000 - 0xffff1fff libSystem.B.dylib ??? (???) <62291026-D016-705D-DC1E-FC2B09D47DE5 /usr/lib/libSystem.B.dylib

    Read the article

  • Grouping data in LINQ with the help of group keyword

    - by vik20000in
    While working with any kind of advanced query grouping is a very important factor. Grouping helps in executing special function like sum, max average etc to be performed on certain groups of data inside the date result set. Grouping is done with the help of the Group method. Below is an example of the basic group functionality.     int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };         var numberGroups =         from num in numbers         group num by num % 5 into numGroup         select new { Remainder = numGroup.Key, Numbers = numGroup };  In the above example we have grouped the values based on the reminder left over when divided by 5. First we are grouping the values based on the reminder when divided by 5 into the numgroup variable.  numGroup.Key gives the value of the key on which the grouping has been applied. And the numGroup itself contains all the records that are contained in that group. Below is another example to explain the same. string[] words = { "blueberry", "abacus", "banana", "apple", "cheese" };         var wordGroups =         from num in words         group num by num[0] into grp         select new { FirstLetter = grp.Key, Words = grp }; In the above example we are grouping the value with the first character of the string (num[0]). Just like the order operator the group by clause also allows us to write our own logic for the Equal comparison (That means we can group Item by ignoring case also by writing out own implementation). For this we need to pass an object that implements the IEqualityComparer<string> interface. Below is an example. public class AnagramEqualityComparer : IEqualityComparer<string> {     public bool Equals(string x, string y) {         return getCanonicalString(x) == getCanonicalString(y);     }      public int GetHashCode(string obj) {         return getCanonicalString(obj).GetHashCode();     }         private string getCanonicalString(string word) {         char[] wordChars = word.ToCharArray();         Array.Sort<char>(wordChars);         return new string(wordChars);     } }  string[] anagrams = {"from   ", " salt", " earn", "  last   ", " near "}; var orderGroups = anagrams.GroupBy(w => w.Trim(), new AnagramEqualityComparer()); Vikram  

    Read the article

  • Unable to build my c++ code with g++ 4.6.3

    - by Mriganka
    I am facing multiple issues with building my c++ code on Ubuntu 12.04. This code was building and running fine on RH Enterprise. I am using g++ 4.6.3. Here's the output of g++ -v. g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) Here's a sample of my code: #include "Word.h" #include < string> using namespace std; pthread_mutex_t Word::_lock = PTHREAD_MUTEX_INITIALIZER; Word::Word(): _occurrences(1) { memset(_buf, 0, 25); } Word::Word(char *str): _occurrences(1) { memset(_buf, 0, 25); if (str != NULL) { strncpy(_buf, str, strlen(str)); } } g++ -c -ansi or g++ -c -std=c++98 or g++ -c -std=c++03, none of these options are able to build the code correctly. I get the following compilation errors: mriganka@ubuntu:~/WordCount$ make g++ -c -g -ansi Word.cpp -o Word.o Word.cpp: In constructor ‘Word::Word()’: Word.cpp:10:21: error: ‘memset’ was not declared in this scope Word.cpp: In constructor ‘Word::Word(char*)’: Word.cpp:16:21: error: ‘memset’ was not declared in this scope Word.cpp:19:34: error: ‘strlen’ was not declared in this scope Word.cpp:19:35: error: ‘strncpy’ was not declared in this scope Word.cpp: In member function ‘void Word::operator=(const Word&)’: Word.cpp:37:42: error: ‘strlen’ was not declared in this scope Word.cpp:37:43: error: ‘strncpy’ was not declared in this scope Word.cpp: In copy constructor ‘Word::Word(const Word&)’: Word.cpp:44:21: error: ‘memset’ was not declared in this scope Word.cpp:45:52: error: ‘strlen’ was not declared in this scope Word.cpp:45:53: error: ‘strncpy’ was not declared in this scope So basically g++ 4.6.3 on Ubuntu 12.04 is not able to recognize the standard c++ headers. And I am not finding a way out of this situation. Second problem: In order to make progress, I included < string.h instead of < string. But now I am facing linking errors with my message queue and pthread library functions. Here's the error that I am getting: mriganka@ubuntu:~/WordCount$ make g++ -c -g -ansi Word.cpp -o Word.o g++ -lrt -I/usr/lib/i386-linux-gnu Word.o HashMap.o main.o -o word_count main.o: In function `main': /home/mriganka/WordCount/main.cpp:75: undefined reference to `pthread_create' /home/mriganka/WordCount/main.cpp:90: undefined reference to `mq_open' /home/mriganka/WordCount/main.cpp:93: undefined reference to `mq_getattr' /home/mriganka/WordCount/main.cpp:113: undefined reference to `mq_send' /home/mriganka/WordCount/main.cpp:123: undefined reference to `pthread_join' /home/mriganka/WordCount/main.cpp:129: undefined reference to `mq_close' /home/mriganka/WordCount/main.cpp:130: undefined reference to `mq_unlink' main.o: In function `count_words(void*)': /home/mriganka/WordCount/main.cpp:151: undefined reference to `mq_open' /home/mriganka/WordCount/main.cpp:154: undefined reference to `mq_getattr' /home/mriganka/WordCount/main.cpp:162: undefined reference to `mq_timedreceive' collect2: ld returned 1 exit status Here's my makefile: CC=g++ CFLAGS=-c -g -ansi LDFLAGS=-lrt INC=-I/usr/lib/i386-linux-gnu SOURCES=Word.cpp HashMap.cpp main.cpp OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=word_count all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(INC) -pthread $(OBJECTS) -o $@ .cpp.o: $(CC) $(CFLAGS) $< -o $@ clean: rm -f *.o word_count Please help me to resolve both the issues. I searched online relentlessly for any solution of these problems, but no one seems to have encountered these issues.

    Read the article

  • Merge sort versus quick sort performance

    - by Giorgio
    I have implemented merge sort and quick sort using C (GCC 4.4.3 on Ubuntu 10.04 running on a 4 GB RAM laptop with an Intel DUO CPU at 2GHz) and I wanted to compare the performance of the two algorithms. The prototypes of the sorting functions are: void merge_sort(const char **lines, int start, int end); void quick_sort(const char **lines, int start, int end); i.e. both take an array of pointers to strings and sort the elements with index i : start <= i <= end. I have produced some files containing random strings with length on average 4.5 characters. The test files range from 100 lines to 10000000 lines. I was a bit surprised by the results because, even though I know that merge sort has complexity O(n log(n)) while quick sort is O(n^2), I have often read that on average quick sort should be as fast as merge sort. However, my results are the following. Up to 10000 strings, both algorithms perform equally well. For 10000 strings, both require about 0.007 seconds. For 100000 strings, merge sort is slightly faster with 0.095 s against 0.121 s. For 1000000 strings merge sort takes 1.287 s against 5.233 s of quick sort. For 5000000 strings merge sort takes 7.582 s against 118.240 s of quick sort. For 10000000 strings merge sort takes 16.305 s against 1202.918 s of quick sort. So my question is: are my results as expected, meaning that quick sort is comparable in speed to merge sort for small inputs but, as the size of the input data grows, the fact that its complexity is quadratic will become evident? Here is a sketch of what I did. In the merge sort implementation, the partitioning consists in calling merge sort recursively, i.e. merge_sort(lines, start, (start + end) / 2); merge_sort(lines, 1 + (start + end) / 2, end); Merging of the two sorted sub-array is performed by reading the data from the array lines and writing it to a global temporary array of pointers (this global array is allocate only once). After each merge the pointers are copied back to the original array. So the strings are stored once but I need twice as much memory for the pointers. For quick sort, the partition function chooses the last element of the array to sort as the pivot and scans the previous elements in one loop. After it has produced a partition of the type start ... {elements <= pivot} ... pivotIndex ... {elements > pivot} ... end it calls itself recursively: quick_sort(lines, start, pivotIndex - 1); quick_sort(lines, pivotIndex + 1, end); Note that this quick sort implementation sorts the array in-place and does not require additional memory, therefore it is more memory efficient than the merge sort implementation. So my question is: is there a better way to implement quick sort that is worthwhile trying out? If I improve the quick sort implementation and perform more tests on different data sets (computing the average of the running times on different data sets) can I expect a better performance of quick sort wrt merge sort? EDIT Thank you for your answers. My implementation is in-place and is based on the pseudo-code I have found on wikipedia in Section In-place version: function partition(array, 'left', 'right', 'pivotIndex') where I choose the last element in the range to be sorted as a pivot, i.e. pivotIndex := right. I have checked the code over and over again and it seems correct to me. In order to rule out the case that I am using the wrong implementation I have uploaded the source code on github (in case you would like to take a look at it). Your answers seem to suggest that I am using the wrong test data. I will look into it and try out different test data sets. I will report as soon as I have some results.

    Read the article

  • Open GL stars are not rendering

    - by Darestium
    I doing Nehe's Open GL Lesson 9. I'm using SFML for windowing, the strange thing is no stars are rendering. #include <SFML/System.hpp> #include <SFML/Window.hpp> #include <SFML/Graphics.hpp> #include <iostream> void processEvents(sf::Window *app); void processInput(sf::Window *app); void renderGlScene(sf::Window *app); void init(); int loadResources(); const int NUM_OF_STARS = 50; float triRot = 0.0f; float quadRot = 0.0f; bool twinkle = false; bool tKey = false; float zoom = 15.0f; float tilt = 90.0f; float spin = 0.0f; unsigned int loop; unsigned int texture_handle[1]; typedef struct { int r, g, b; float distance; float angle; } stars; stars star[NUM_OF_STARS]; int main() { sf::Window app(sf::VideoMode(800, 600, 32), "Nehe Lesson 9"); app.UseVerticalSync(false); init(); if (loadResources() == -1) { return EXIT_FAILURE; } while (app.IsOpened()) { processEvents(&app); processInput(&app); renderGlScene(&app); app.Display(); } return EXIT_SUCCESS; } int loadResources() { sf::Image img_data; // Load Texture if (!img_data.LoadFromFile("data/images/star.bmp")) { std::cout << "Could not load data/images/star.bmp"; return -1; } // Generate 1 texture glGenTextures(1, &texture_handle[0]); // Linear filtering glBindTexture(GL_TEXTURE_2D, texture_handle[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img_data.GetWidth(), img_data.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, img_data.GetPixelsPtr()); return 0; } void processInput(sf::Window *app) { const sf::Input& input = app->GetInput(); if (input.IsKeyDown(sf::Key::T) && !tKey) { tKey = true; twinkle = !twinkle; } if (!input.IsKeyDown(sf::Key::T)) { tKey = false; } if (input.IsKeyDown(sf::Key::Up)) { tilt -= 0.05f; } if (input.IsKeyDown(sf::Key::Down)) { tilt += 0.05f; } if (input.IsKeyDown(sf::Key::PageUp)) { zoom -= 0.02f; } if (input.IsKeyDown(sf::Key::Up)) { zoom += 0.02f; } } void init() { glClearDepth(1.f); glClearColor(0.f, 0.f, 0.f, 0.f); // Enable texturing glEnable(GL_TEXTURE_2D); //glDepthMask(GL_TRUE); // Setup a perpective projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.f, 1.f, 1.f, 500.f); glShadeModel(GL_SMOOTH); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); for (loop = 0; loop < NUM_OF_STARS; loop++) { star[loop].distance = (float)loop / NUM_OF_STARS * 5.0f; // Calculate distance from the centre // Give stars random rgb value star[loop].r = rand() % 256; star[loop].g = rand() % 256; star[loop].b = rand() % 256; } } void processEvents(sf::Window *app) { sf::Event event; while (app->GetEvent(event)) { if (event.Type == sf::Event::Closed) { app->Close(); } if (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Key::Escape) { app->Close(); } } } void renderGlScene(sf::Window *app) { app->SetActive(); // Clear color depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Apply some transformations glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Select texture glBindTexture(GL_TEXTURE_2D, texture_handle[0]); for (loop = 0; loop < NUM_OF_STARS; loop++) { glLoadIdentity(); // Reset The View Before We Draw Each Star glTranslatef(0.0f, 0.0f, zoom); // Zoom Into The Screen (Using The Value In 'zoom') glRotatef(tilt, 1.0f, 0.0f, 0.0f); // Tilt The View (Using The Value In 'tilt') glRotatef(star[loop].angle, 0.0f, 1.0f, 0.0f); // Rotate To The Current Stars Angle glTranslatef(star[loop].distance, 0.0f, 0.0f); // Move Forward On The X Plane glRotatef(-star[loop].angle,0.0f,1.0f,0.0f); // Cancel The Current Stars Angle glRotatef(-tilt,1.0f,0.0f,0.0f); // Cancel The Screen Tilt if (twinkle) { glColor4ub(star[(NUM_OF_STARS - loop) - 1].r, star[(NUM_OF_STARS - loop)-1].g, star[(NUM_OF_STARS - loop) - 1].b, 255); glBegin(GL_QUADS); // Begin Drawing The Textured Quad glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f); glEnd(); // Done Drawing The Textured Quad } glRotatef(spin,0.0f,0.0f,1.0f); // Rotate The Star On The Z Axis // Assign A Color Using Bytes glColor4ub(star[loop].r, star[loop].g, star[loop].b, 255); glBegin(GL_QUADS); // Begin Drawing The Textured Quad glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f); glEnd(); // Done Drawing The Textured Quad spin += 0.01f; // Used To Spin The Stars star[loop].angle += (float)loop / NUM_OF_STARS; // Changes The Angle Of A Star star[loop].distance -= 0.01f; // Changes The Distance Of A Star if (star[loop].distance < 0.0f) { star[loop].distance += 5.0f; // Move The Star 5 Units From The Center star[loop].r = rand() % 256; // Give It A New Red Value star[loop].g = rand() % 256; // Give It A New Green Value star[loop].b = rand() % 256; // Give It A New Blue Value } } } I've looked over the code atleast 10 times now and I can't figure out the problem. Any help would be much appreciated.

    Read the article

  • Benchmarking MySQL Replication with Multi-Threaded Slaves

    - by Mat Keep
    0 0 1 1145 6530 Homework 54 15 7660 14.0 Normal 0 false false false EN-US JA X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:Cambria; mso-ascii-font-family:Cambria; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Cambria; mso-hansi-theme-font:minor-latin; mso-ansi-language:EN-US;} The objective of this benchmark is to measure the performance improvement achieved when enabling the Multi-Threaded Slave enhancement delivered as a part MySQL 5.6. As the results demonstrate, Multi-Threaded Slaves delivers 5x higher replication performance based on a configuration with 10 databases/schemas. For real-world deployments, higher replication performance directly translates to: · Improved consistency of reads from slaves (i.e. reduced risk of reading "stale" data) · Reduced risk of data loss should the master fail before replicating all events in its binary log (binlog) The multi-threaded slave splits processing between worker threads based on schema, allowing updates to be applied in parallel, rather than sequentially. This delivers benefits to those workloads that isolate application data using databases - e.g. multi-tenant systems deployed in cloud environments. Multi-Threaded Slaves are just one of many enhancements to replication previewed as part of the MySQL 5.6 Development Release, which include: · Global Transaction Identifiers coupled with MySQL utilities for automatic failover / switchover and slave promotion · Crash Safe Slaves and Binlog · Optimized Row Based Replication · Replication Event Checksums · Time Delayed Replication These and many more are discussed in the “MySQL 5.6 Replication: Enabling the Next Generation of Web & Cloud Services” Developer Zone article  Back to the benchmark - details are as follows. Environment The test environment consisted of two Linux servers: · one running the replication master · one running the replication slave. Only the slave was involved in the actual measurements, and was based on the following configuration: - Hardware: Oracle Sun Fire X4170 M2 Server - CPU: 2 sockets, 6 cores with hyper-threading, 2930 MHz. - OS: 64-bit Oracle Enterprise Linux 6.1 - Memory: 48 GB Test Procedure Initial Setup: Two MySQL servers were started on two different hosts, configured as replication master and slave. 10 sysbench schemas were created, each with a single table: CREATE TABLE `sbtest` (    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,    `k` int(10) unsigned NOT NULL DEFAULT '0',    `c` char(120) NOT NULL DEFAULT '',    `pad` char(60) NOT NULL DEFAULT '',    PRIMARY KEY (`id`),    KEY `k` (`k`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 10,000 rows were inserted in each of the 10 tables, for a total of 100,000 rows. When the inserts had replicated to the slave, the slave threads were stopped. The slave data directory was copied to a backup location and the slave threads position in the master binlog noted. 10 sysbench clients, each configured with 10 threads, were spawned at the same time to generate a random schema load against each of the 10 schemas on the master. Each sysbench client executed 10,000 "update key" statements: UPDATE sbtest set k=k+1 WHERE id = <random row> In total, this generated 100,000 update statements to later replicate during the test itself. Test Methodology: The number of slave workers to test with was configured using: SET GLOBAL slave_parallel_workers=<workers> Then the slave IO thread was started and the test waited for all the update queries to be copied over to the relay log on the slave. The benchmark clock was started and then the slave SQL thread was started. The test waited for the slave SQL thread to finish executing the 100k update queries, doing "select master_pos_wait()". When master_pos_wait() returned, the benchmark clock was stopped and the duration calculated. The calculated duration from the benchmark clock should be close to the time it took for the SQL thread to execute the 100,000 update queries. The 100k queries divided by this duration gave the benchmark metric, reported as Queries Per Second (QPS). Test Reset: The test-reset cycle was implemented as follows: · the slave was stopped · the slave data directory replaced with the previous backup · the slave restarted with the slave threads replication pointer repositioned to the point before the update queries in the binlog. The test could then be repeated with identical set of queries but a different number of slave worker threads, enabling a fair comparison. The Test-Reset cycle was repeated 3 times for 0-24 number of workers and the QPS metric calculated and averaged for each worker count. MySQL Configuration The relevant configuration settings used for MySQL are as follows: binlog-format=STATEMENT relay-log-info-repository=TABLE master-info-repository=TABLE As described in the test procedure, the slave_parallel_workers setting was modified as part of the test logic. The consequence of changing this setting is: 0 worker threads:    - current (i.e. single threaded) sequential mode    - 1 x IO thread and 1 x SQL thread    - SQL thread both reads and executes the events 1 worker thread:    - sequential mode    - 1 x IO thread, 1 x Coordinator SQL thread and 1 x Worker thread    - coordinator reads the event and hands it to the worker who executes 2+ worker threads:    - parallel execution    - 1 x IO thread, 1 x Coordinator SQL thread and 2+ Worker threads    - coordinator reads events and hands them to the workers who execute them Results Figure 1 below shows that Multi-Threaded Slaves deliver ~5x higher replication performance when configured with 10 worker threads, with the load evenly distributed across our 10 x schemas. This result is compared to the current replication implementation which is based on a single SQL thread only (i.e. zero worker threads). Figure 1: 5x Higher Performance with Multi-Threaded Slaves The following figure shows more detailed results, with QPS sampled and reported as the worker threads are incremented. The raw numbers behind this graph are reported in the Appendix section of this post. Figure 2: Detailed Results As the results above show, the configuration does not scale noticably from 5 to 9 worker threads. When configured with 10 worker threads however, scalability increases significantly. The conclusion therefore is that it is desirable to configure the same number of worker threads as schemas. Other conclusions from the results: · Running with 1 worker compared to zero workers just introduces overhead without the benefit of parallel execution. · As expected, having more workers than schemas adds no visible benefit. Aside from what is shown in the results above, testing also demonstrated that the following settings had a very positive effect on slave performance: relay-log-info-repository=TABLE master-info-repository=TABLE For 5+ workers, it was up to 2.3 times as fast to run with TABLE compared to FILE. Conclusion As the results demonstrate, Multi-Threaded Slaves deliver significant performance increases to MySQL replication when handling multiple schemas. This, and the other replication enhancements introduced in MySQL 5.6 are fully available for you to download and evaluate now from the MySQL Developer site (select Development Release tab). You can learn more about MySQL 5.6 from the documentation  Please don’t hesitate to comment on this or other replication blogs with feedback and questions. Appendix – Detailed Results

    Read the article

  • Nvidia drivers don't work with mainline kernel

    - by dutchie
    I want to try some of the new features in the btrfs filesystem, and to do that I need to use a newer kernel than is included in Ubuntu 12.04. To do that, I have installed linux-headers-3.4.0-030400_3.4.0-030400.201205210521_all.deb, linux-headers-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb, and linux-image-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb from the mainline kernel download here. However, on rebooting into the 3.4 kernel, my desktop is stuck at a very low resolution and I cannot increase it to the full. This did happen when I first installed, but a simple install of the nvidia-current package got everything working nicely with my GTX570 card. There were appear to be some DKMS errors when I installed the kernel, and they indicated I should look at /var/lib/dkms/nvidia-current/295.40/build/make.log: josh@sirius:~/Downloads$ sudo dpkg -i linux-*.deb Selecting previously unselected package linux-headers-3.4.0-030400. (Reading database ... 309400 files and directories currently installed.) Unpacking linux-headers-3.4.0-030400 (from linux-headers-3.4.0-030400_3.4.0-030400.201205210521_all.deb) ... Selecting previously unselected package linux-headers-3.4.0-030400-generic. Unpacking linux-headers-3.4.0-030400-generic (from linux-headers-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb) ... Selecting previously unselected package linux-image-3.4.0-030400-generic. Unpacking linux-image-3.4.0-030400-generic (from linux-image-3.4.0-030400-generic_3.4.0-030400.201205210521_amd64.deb) ... Done. Setting up linux-headers-3.4.0-030400 (3.4.0-030400.201205210521) ... Setting up linux-headers-3.4.0-030400-generic (3.4.0-030400.201205210521) ... Examining /etc/kernel/header_postinst.d. run-parts: executing /etc/kernel/header_postinst.d/dkms 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic ERROR (dkms apport): kernel package linux-headers-3.4.0-030400-generic is not supported Error! Bad return status for module build on kernel: 3.4.0-030400-generic (x86_64) Consult /var/lib/dkms/nvidia-current/295.40/build/make.log for more information. Setting up linux-image-3.4.0-030400-generic (3.4.0-030400.201205210521) ... Running depmod. update-initramfs: deferring update (hook will be called later) Examining /etc/kernel/postinst.d. run-parts: executing /etc/kernel/postinst.d/dkms 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic ERROR (dkms apport): kernel package linux-headers-3.4.0-030400-generic is not supported Error! Bad return status for module build on kernel: 3.4.0-030400-generic (x86_64) Consult /var/lib/dkms/nvidia-current/295.40/build/make.log for more information. run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic update-initramfs: Generating /boot/initrd.img-3.4.0-030400-generic run-parts: executing /etc/kernel/postinst.d/pm-utils 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic run-parts: executing /etc/kernel/postinst.d/update-notifier 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.4.0-030400-generic /boot/vmlinuz-3.4.0-030400-generic Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.4.0-030400-generic Found initrd image: /boot/initrd.img-3.4.0-030400-generic Found linux image: /boot/vmlinuz-3.2.0-24-generic Found initrd image: /boot/initrd.img-3.2.0-24-generic Found memtest86+ image: /memtest86+.bin Found Ubuntu 12.04 LTS (12.04) on /dev/sda1 Found Windows 7 (loader) on /dev/sda2 Found Windows 7 (loader) on /dev/sda3 done /var/lib/dkms/nvidia-current/295.40/build/make.log: DKMS make.log for nvidia-current-295.40 for kernel 3.4.0-030400-generic (x86_64) Thu Jun 7 00:58:39 BST 2012 NVIDIA: calling KBUILD... test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \ echo; \ echo " ERROR: Kernel configuration is invalid."; \ echo " include/generated/autoconf.h or include/config/auto.conf are missing.";\ echo " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ echo; \ /bin/false) mkdir -p /var/lib/dkms/nvidia-current/295.40/build/.tmp_versions ; rm -f /var/lib/dkms/nvidia-current/295.40/build/.tmp_versions/* make -f scripts/Makefile.build obj=/var/lib/dkms/nvidia-current/295.40/build cc -Wp,-MD,/var/lib/dkms/nvidia-current/295.40/build/.nv.o.d -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include -I/usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include -Iarch/x86/include/generated -Iinclude -include /usr/src/linux-headers-3.4.0-030400-generic/include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -Wframe-larger-than=1024 -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -I/var/lib/dkms/nvidia-current/295.40/build -Wall -MD -Wsign-compare -Wno-cast-qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"295.40\" -Wno-unused-function -Wuninitialized -mno-red-zone -mcmodel=kernel -UDEBUG -U_DEBUG -DNDEBUG -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(nv)" -D"KBUILD_MODNAME=KBUILD_STR(nvidia)" -c -o /var/lib/dkms/nvidia-current/295.40/build/.tmp_nv.o /var/lib/dkms/nvidia-current/295.40/build/nv.c In file included from include/linux/kernel.h:19:0, from include/linux/sched.h:55, from include/linux/utsname.h:35, from /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h:38, from /var/lib/dkms/nvidia-current/295.40/build/nv.c:13: include/linux/bitops.h: In function ‘hweight_long’: include/linux/bitops.h:66:41: warning: signed and unsigned type in conditional expression [-Wsign-compare] In file included from /usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include/asm/uaccess.h:577:0, from include/linux/poll.h:14, from /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h:97, from /var/lib/dkms/nvidia-current/295.40/build/nv.c:13: /usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include/asm/uaccess_64.h: In function ‘copy_from_user’: /usr/src/linux-headers-3.4.0-030400-generic/arch/x86/include/asm/uaccess_64.h:53:6: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] In file included from /var/lib/dkms/nvidia-current/295.40/build/nv.c:13:0: /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h: At top level: /var/lib/dkms/nvidia-current/295.40/build/nv-linux.h:114:75: fatal error: asm/system.h: No such file or directory compilation terminated. make[3]: *** [/var/lib/dkms/nvidia-current/295.40/build/nv.o] Error 1 make[2]: *** [_module_/var/lib/dkms/nvidia-current/295.40/build] Error 2 NVIDIA: left KBUILD. nvidia.ko failed to build! make[1]: *** [module] Error 1 make: *** [module] Error 2

    Read the article

  • C++ OpenGL wireframe cube rendering blank

    - by caleb.breckon
    I'm just trying to draw a bunch of lines that make up a "cube". I can't for the life of me figure out why this is producing a black screen. The debugger does not break at any point. I'm sure it's a problem with my pointers, as I'm only decent at them in regular c++ and in OpenGL it gets even worse. const char* vertexSource = "#version 150\n" "in vec3 position;" "void main() {" " gl_Position = vec4(position, 1.0);" "}"; const char* fragmentSource = "#version 150\n" "out vec4 outColor;" "void main() {" " outColor = vec4(1.0, 1.0, 1.0, 1.0);" "}"; int main() { initializeGLFW(); // Initialize GLEW glewExperimental = GL_TRUE; glewInit(); // Create Vertex Array Object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); // Create a Vertex Buffer Object and copy the vertex data to it GLuint vbo; glGenBuffers( 1, &vbo ); float vertices[] = { 1.0f, 1.0f, 1.0f, // Vertex 0 (X, Y, Z) -1.0f, 1.0f, 1.0f, // Vertex 1 (X, Y, Z) -1.0f, -1.0f, 1.0f, // Vertex 2 (X, Y, Z) 1.0f, -1.0f, 1.0f, // Vertex 3 (X, Y, Z) 1.0f, 1.0f, -1.0f, // Vertex 4 (X, Y, Z) -1.0f, 1.0f, -1.0f, // Vertex 5 (X, Y, Z) -1.0f, -1.0f, -1.0f, // Vertex 6 (X, Y, Z) 1.0f, -1.0f, -1.0f // Vertex 7 (X, Y, Z) }; GLuint indices[] = { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 }; glBindBuffer( GL_ARRAY_BUFFER, vbo ); glBufferData( GL_ARRAY_BUFFER, sizeof( vertices ), vertices, GL_STATIC_DRAW ); //glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, vbo); //glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( indices ), indices, GL_STATIC_DRAW ); // Create and compile the vertex shader GLuint vertexShader = glCreateShader( GL_VERTEX_SHADER ); glShaderSource( vertexShader, 1, &vertexSource, NULL ); glCompileShader( vertexShader ); // Create and compile the fragment shader GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER ); glShaderSource( fragmentShader, 1, &fragmentSource, NULL ); glCompileShader( fragmentShader ); // Link the vertex and fragment shader into a shader program GLuint shaderProgram = glCreateProgram(); glAttachShader( shaderProgram, vertexShader ); glAttachShader( shaderProgram, fragmentShader ); glBindFragDataLocation( shaderProgram, 0, "outColor" ); glLinkProgram (shaderProgram); glUseProgram( shaderProgram); // Specify the layout of the vertex data GLint posAttrib = glGetAttribLocation( shaderProgram, "position" ); glEnableVertexAttribArray( posAttrib ); glVertexAttribPointer( posAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0 ); // Main loop while(glfwGetWindowParam(GLFW_OPENED)) { // Clear the screen to black glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT ); // Draw lines from 2 vertices glDrawElements(GL_LINES, sizeof(indices), GL_UNSIGNED_INT, indices ); // Swap buffers glfwSwapBuffers(); } // Clean up glDeleteProgram( shaderProgram ); glDeleteShader( fragmentShader ); glDeleteShader( vertexShader ); //glDeleteBuffers( 1, &ebo ); glDeleteBuffers( 1, &vbo ); glDeleteVertexArrays( 1, &vao ); glfwTerminate(); exit( EXIT_SUCCESS ); }

    Read the article

  • Strings in .NET are Enumerable

    - by Scott Dorman
    It seems like there is always some confusion concerning strings in .NET. This is both from developers who are new to the Framework and those that have been working with it for quite some time. Strings in the .NET Framework are represented by the System.String class, which encapsulates the data manipulation, sorting, and searching methods you most commonly perform on string data. In the .NET Framework, you can use System.String (which is the actual type name or the language alias (for C#, string). They are equivalent so use whichever naming convention you prefer but be consistent. Common usage (and my preference) is to use the language alias (string) when referring to the data type and String (the actual type name) when accessing the static members of the class. Many mainstream programming languages (like C and C++) treat strings as a null terminated array of characters. The .NET Framework, however, treats strings as an immutable sequence of Unicode characters which cannot be modified after it has been created. Because strings are immutable, all operations which modify the string contents are actually creating new string instances and returning those. They never modify the original string data. There is one important word in the preceding paragraph which many people tend to miss: sequence. In .NET, strings are treated as a sequence…in fact, they are treated as an enumerable sequence. This can be verified if you look at the class declaration for System.String, as seen below: // Summary:// Represents text as a series of Unicode characters.public sealed class String : IEnumerable, IComparable, IComparable<string>, IEquatable<string> The first interface that String implements is IEnumerable, which has the following definition: // Summary:// Exposes the enumerator, which supports a simple iteration over a non-generic// collection.public interface IEnumerable{ // Summary: // Returns an enumerator that iterates through a collection. // // Returns: // An System.Collections.IEnumerator object that can be used to iterate through // the collection. IEnumerator GetEnumerator();} As a side note, System.Array also implements IEnumerable. Why is that important to know? Simply put, it means that any operation you can perform on an array can also be performed on a string. This allows you to write code such as the following: string s = "The quick brown fox";foreach (var c in s){ System.Diagnostics.Debug.WriteLine(c);}for (int i = 0; i < s.Length; i++){ System.Diagnostics.Debug.WriteLine(s[i]);} If you executed those lines of code in a running application, you would see the following output in the Visual Studio Output window: In the case of a string, these enumerable or array operations return a char (System.Char) rather than a string. That might lead you to believe that you can get around the string immutability restriction by simply treating strings as an array and assigning a new character to a specific index location inside the string, like this: string s = "The quick brown fox";s[2] = 'a';   However, if you were to write such code, the compiler will promptly tell you that you can’t do it: This preserves the notion that strings are immutable and cannot be changed once they are created. (Incidentally, there is no built in way to replace a single character like this. It can be done but it would require converting the string to a character array, changing the appropriate indexed location, and then creating a new string.)

    Read the article

  • C#, Delegates and LINQ

    - by JustinGreenwood
    One of the topics many junior programmers struggle with is delegates. And today, anonymous delegates and lambda expressions are profuse in .net APIs.  To help some VB programmers adapt to C# and the many equivalent flavors of delegates, I walked through some simple samples to show them the different flavors of delegates. using System; using System.Collections.Generic; using System.Linq; namespace DelegateExample { class Program { public delegate string ProcessStringDelegate(string data); public static string ReverseStringStaticMethod(string data) { return new String(data.Reverse().ToArray()); } static void Main(string[] args) { var stringDelegates = new List<ProcessStringDelegate> { //========================================================== // Declare a new delegate instance and pass the name of the method in new ProcessStringDelegate(ReverseStringStaticMethod), //========================================================== // A shortcut is to just and pass the name of the method in ReverseStringStaticMethod, //========================================================== // You can create an anonymous delegate also delegate (string inputString) //Scramble { var outString = inputString; if (!string.IsNullOrWhiteSpace(inputString)) { var rand = new Random(); var chs = inputString.ToCharArray(); for (int i = 0; i < inputString.Length * 3; i++) { int x = rand.Next(chs.Length), y = rand.Next(chs.Length); char c = chs[x]; chs[x] = chs[y]; chs[y] = c; } outString = new string(chs); } return outString; }, //========================================================== // yet another syntax would be the lambda expression syntax inputString => { // ROT13 var array = inputString.ToCharArray(); for (int i = 0; i < array.Length; i++) { int n = (int)array[i]; n += (n >= 'a' && n <= 'z') ? ((n > 'm') ? 13 : -13) : ((n >= 'A' && n <= 'Z') ? ((n > 'M') ? 13 : -13) : 0); array[i] = (char)n; } return new string(array); } //========================================================== }; // Display the results of the delegate calls var stringToTransform = "Welcome to the jungle!"; System.Console.ForegroundColor = ConsoleColor.Cyan; System.Console.Write("String to Process: "); System.Console.ForegroundColor = ConsoleColor.Yellow; System.Console.WriteLine(stringToTransform); stringDelegates.ForEach(delegatePointer => { System.Console.WriteLine(); System.Console.ForegroundColor = ConsoleColor.Cyan; System.Console.Write("Delegate Method Name: "); System.Console.ForegroundColor = ConsoleColor.Magenta; System.Console.WriteLine(delegatePointer.Method.Name); System.Console.ForegroundColor = ConsoleColor.Cyan; System.Console.Write("Delegate Result: "); System.Console.ForegroundColor = ConsoleColor.White; System.Console.WriteLine(delegatePointer(stringToTransform)); }); System.Console.ReadKey(); } } } The output of the program is below: String to Process: Welcome to the jungle! Delegate Method Name: ReverseStringStaticMethod Delegate Result: !elgnuj eht ot emocleW Delegate Method Name: ReverseStringStaticMethod Delegate Result: !elgnuj eht ot emocleW Delegate Method Name: b__1 Delegate Result: cg ljotWotem!le une eh Delegate Method Name: b__2 Delegate Result: dX_V|`X ?| ?[X ]?{Z_X!

    Read the article

< Previous Page | 117 118 119 120 121 122 123 124 125 126 127 128  | Next Page >