Daily Archives

Articles indexed Sunday June 13 2010

Page 30/73 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • I'm new to C++. Please Help me with the Linked List (What functions to add)?

    - by Igal
    DEAR All; Hi, I'm just beginner to C++; Please help me to understand: What functions should be in the Linked list class ? I think there should be overloaded operators << and ; Please help me to improve the code (style, errors, etc,) Thanks for advance. Igal. Please review the small code for the integer List (enclosed MyNODE.h and ListDriver1.cpp); MyNODE.h // This is my first attempt to write linked list. Igal Spector, June 2010. #include <iostream.h> #include <assert.h> //Forward Declaration of the classes: class ListNode; class TheLinkedlist; // Definition of the node (WITH IMPLEMENTATION !!!, without test drive): class ListNode{ friend class TheLinkedlist; public: // constructor: ListNode(const int& value, ListNode *next= 0); // note: no destructor, as this handled by TheLinkedList class. // accessor: return data in the node. // int Show() const {return theData;} private: int theData; //the Data ListNode* theNext; //points to the next node in the list. }; //Implementations: //constructor: inline ListNode::ListNode(const int &value,ListNode *next) :theData(value),theNext(next){} //end of ListNode class, now for the LL class: class TheLinkedlist { public: //constructors: TheLinkedlist(); virtual ~TheLinkedlist(); // Accessors: void InsertAtFront(const &); void AppendAtBack(const &); // void InOrderInsert(const &); bool IsEmpty()const;//predicate function void Print() const; private: ListNode * Head; //pointer to first node ListNode * Tail; //pointer to last node. }; //Implementation: //Default constructor inline TheLinkedlist::TheLinkedlist():Head(0),Tail(0) {} //Destructor inline TheLinkedlist::~TheLinkedlist(){ if(!IsEmpty()){ //list is not empty cout<<"\n\tDestroying Nodes"<<endl; ListNode *currentPointer=Head, *tempPtr; while(currentPointer != 0){ //Delete remaining Nodes. tempPtr=currentPointer; cout<<"The node: "<<tempPtr->theData <<" is Destroyed."<<endl<<endl; currentPointer=currentPointer->theNext; delete tempPtr; } Head=Tail = 0; //don't forget this, as it may be checked one day. } } //Insert the Node to the beginning of the list: void TheLinkedlist::InsertAtFront(const int& value){ ListNode *newPtr = new ListNode(value,Head); assert(newPtr!=0); if(IsEmpty()) //list is empty Head = Tail = newPtr; else { //list is NOT empty newPtr->theNext = Head; Head = newPtr; } } //Insert the Node to the beginning of the list: void TheLinkedlist::AppendAtBack(const int& value){ ListNode *newPtr = new ListNode(value, NULL); assert(newPtr!=0); if(IsEmpty()) //list is empty Head = Tail = newPtr; else { //list is NOT empty Tail->theNext = newPtr; Tail = newPtr; } } //is the list empty? inline bool TheLinkedlist::IsEmpty() const { return (Head == 0); } // Display the contents of the list void TheLinkedlist::Print()const{ if ( IsEmpty() ){ cout << "\n\t The list is empty!!"<<endl; return; } ListNode *tempPTR = Head; cout<<"\n\t The List is: "; while ( tempPTR != 0 ){ cout<< tempPTR->theData <<" "; tempPTR = tempPTR->theNext; } cout<<endl<<endl; } ////////////////////////////////////// The test Driver: //Driver test for integer Linked List. #include <iostream.h> #include "MyNODE.h" // main Driver int main(){ cout<< "\n\t This is the test for integer LinkedList."<<endl; const int arraySize=11, ARRAY[arraySize]={44,77,88,99,11,2,22,204,50,58,12}; cout << "\n\tThe array is: "; //print the numbers. for (int i=0;i<arraySize; i++) cout<<ARRAY[i]<<", "; TheLinkedlist list; //declare the list for(int index=0;index<arraySize;index++) list.AppendAtBack( ARRAY[index] );//create the list cout<<endl<<endl; list.Print(); //print the list return 0; //end of the program. }

    Read the article

  • log4j prints all levels

    - by Florian
    Hello, I've got log4j configured on my Java project with the following log4j.properties: log4j.rootLogger=WARNING, X log4j.appender.X=org.apache.log4j.ConsoleAppender log4j.appender.X.layout=org.apache.log4j.PatternLayout log4j.appender.X.layout.ConversionPattern=%p %m %n log4j.logger.org.hibernate.SQL=WARNING log4j.logger.com.****.services.clarity.dao.impl=WARNING log4j.logger.com.****.services.clarity.controller=WARNING log4j.logger.com.****.services.clarity.services.impl=WARNING log4j.logger.com.****.services.clarity.feeds.impl=WARNING As configured, it should only print WARNING messages, however it prints all levels to DEBUG. any ideas where this can come from ? Thanks !

    Read the article

  • Working with extra fields in an Inline form - save_model, save_formset, can't make sense of the diff

    - by magicrebirth
    Suppose I am in the usual situation where there're extra fields in the many2many relationship: class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Person) group = models.ForeignKey(Group) date_joined = models.DateField() invite_reason = models.CharField(max_length=64) # other models which are unrelated to the ones above.. class Trip(models.Model): placeVisited = models.ForeignKey(Place) visitor = models.ForeignKey(Person) pleasuretrip = models.Boolean() class Place(models.Model): name = models.CharField(max_length=128) I want to add some extra fields in the Membership form that gets displayed through the Inline. These fields basically are a shortcut to the instantiation of another model (Trip). Trip can have its own admin views, but these shortcuts are needed because when my project partners are entering 'Membership' data in the system they happen to have also the 'Trip' information handy (and also because some of the info in Membership can just be copied over to Trip etc. etc.). So all I want to have is two extra fields in the Membership Inline - placeVisited and pleasuretrip - which together with the Person instance will let me instantiate the Trip model in the background... I found out I can easily add extra fields to the inline view by defining my own form. But once the data have been entered, how and when to reference to them in order to perform the save operations I need to do? class MyForm(forms.ModelForm): place = forms.ModelChoiceField(required=False, queryset=Place.objects.all(), label="place",) pleasuretrip = forms.BooleanField(required=False, label="...") class MembershipInline(admin.TabularInline): model = Membership form = MyForm def save_model(self, request, obj, form, change): place = form.place pleasuretrip = form.pleasuretrip person = form.person .... # now I can create Trip instances with those data .... obj.save() class GroupAdmin(admin.ModelAdmin): model = Group .... inlines = (MembershipInline,) This doesn't seem to work... I'm also a bit puzzled by the save_formset method... maybe is that the one I should be using? Many thanks in advance for the help!!!!

    Read the article

  • Is -1 a magic number? An anti-pattern? A code smell? Quotes and guidelines from authorities

    - by polygenelubricants
    I've seen -1 used in various APIs, most commonly when searching into a "collection" with zero-based indices, usually to indicate the "not found" index. This "works" because -1 is never a legal index to begin with. It seems that any negative number should work, but I think -1 is almost always used, as some sort of (unwritten?) convention. I would like to limit the scope to Java at least for now. My questions are: What are the official words from Sun regarding using -1 as a "special" return value like this? What quotes are there regarding this issue, from e.g. James Gosling, Josh Bloch, or even other authoritative figures outside of Java? What were some of the notable discussions regarding this issue in the past?

    Read the article

  • How can change my TabHost ?

    - by enricozhang
    I have a tabhost, e.g: final TabHost tabs = getTabHost(); tabs.setup(); TabHost.TabSpec spec = null; spec = tabs.newTabSpec("search"); spec.setContent(new Intent(this, Search.class)); spec.setIndicator("search"); tabs.addTab(spec); in this tabhost is a Intent,and in the activity must change to other activity, question is I hope the other actitivy at same tabhost switch? Can do this?

    Read the article

  • MySQL Paritioning performance

    - by Imran Pathan
    Measured performance on key partitioned tables and normal tables separately. But we couldn't find any performance improvement with partitioning. Queries are pruned. Using MySQL 5.1.47 on RHEL 4. Table details: UserUsage - Will have entries for user mobile number and data usage for each date. Mobile number and Date as PRI KEY. UserProfile - Queries prev table and stores summary for each mobile number. Mobile number PRI KEY. CREATE TABLE `UserUsage` ( `Msisdn` decimal(20,0) NOT NULL, `Date` date NOT NULL, . . PRIMARY KEY USING BTREE (`Msisdn`,`Date`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY KEY(Msisdn) PARTITIONS 50; CREATE TABLE `UserProfile` ( `Msisdn` decimal(20,0) NOT NULL, . . PRIMARY KEY (`Msisdn`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY KEY(Msisdn) PARTITIONS 50; Second table is updated by query select and order by date in first table in a perl program, query is select * from UserUsage where Msisdn=number order by Date desc limit 7 [Process data in perl] update UserProfile values(....) where Msisdn=number explain partition for select, shows row being scanned in a particular partition only. Is something wrong with partition design or queries as partitioning is taking almost same or more time compared to normal tables?

    Read the article

  • Can this Query be corrected or different table structure needed? (database dumps provided)

    - by sandeepan
    This is a bit lengthy but I have provided sufficient details and kept things very clear. Please see if you can help. (I will surely accept answer if it solves my problem) I am sure a person experienced with this can surely help or suggest me to decide the tables structure. About the system:- There are tutors who create classes A tags based search approach is being followed Tag relations are created/edited when new tutors registers/edits profile data and when tutors create classes (this makes tutors and classes searcheable).For simplicity, let us consider only tutor name and class name are the fields which are matched against search keywords. In this example, I am considering - tutor "Sandeepan Nath" has created a class called "first class" tutor "Bob Cratchit" has created a class called "new class" Desired search results- AND logic to be appied on the search keywords and match against class and tutor data(class name + tutor name), in other words, All those classes be shown such that all the search terms are present in the class name or its tutor name. Example to be clear - Searching "first class" returns class with id_wc = 1. Working Searching "Sandeepan class" should also return class with id_wc = 1. Not working in System 2. Problem with profile editing and searching To tell in one sentence, I am facing a conflict between the ease of profile edition (edition of tag relations when tutor profiles are edited) and the ease of search logic. In the beginning, we had one table structure and search was easy but tag edition logic was very clumsy and unmaintainable(Check System 1 in the section below) . So we created separate tag relations tables to make profile edition simpler but search has become difficult. Please dump the tables so that you can run the search query I have given below and see the results. System 1 (previous system - search easy - profile edition difficult):- Only one table called All_Tag_Relations table had the all the tag relations. The tags table below is common to both systems 1 and 2. CREATE TABLE IF NOT EXISTS `all_tag_relations` ( `id_tag_rel` int(10) NOT NULL AUTO_INCREMENT, `id_tag` int(10) unsigned NOT NULL DEFAULT '0', `id_tutor` int(10) DEFAULT NULL, `id_wc` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id_tag_rel`), KEY `All_Tag_Relations_FKIndex1` (`id_tag`), KEY `id_wc` (`id_wc`), KEY `id_tag` (`id_tag`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `all_tag_relations` (`id_tag_rel`, `id_tag`, `id_tutor`, `id_wc`) VALUES (1, 1, 1, NULL), (2, 2, 1, NULL), (3, 1, 1, 1), (4, 2, 1, 1), (5, 3, 1, 1), (6, 4, 1, 1), (7, 6, 2, NULL), (8, 7, 2, NULL), (9, 6, 2, 2), (10, 7, 2, 2), (11, 5, 2, 2), (12, 4, 2, 2); CREATE TABLE IF NOT EXISTS `tags` ( `id_tag` int(10) unsigned NOT NULL AUTO_INCREMENT, `tag` varchar(255) DEFAULT NULL, PRIMARY KEY (`id_tag`), UNIQUE KEY `tag` (`tag`), KEY `id_tag` (`id_tag`), KEY `tag_2` (`tag`), KEY `tag_3` (`tag`), KEY `tag_4` (`tag`), FULLTEXT KEY `tag_5` (`tag`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; INSERT INTO `tags` (`id_tag`, `tag`) VALUES (1, 'Sandeepan'), (2, 'Nath'), (3, 'first'), (4, 'class'), (5, 'new'), (6, 'Bob'), (7, 'Cratchit'); Please note that for every class, the tag rels of its tutor have to be duplicated. Example, for class with id_wc=1, the tag rel records with id_tag_rel = 3 and 4 are actually extras if you compare with the tag rel records with id_tag_rel = 1 and 2. System 2 (present system - profile edition easy, search difficult) Two separate tables Tutors_Tag_Relations and Webclasses_Tag_Relations have the corresponding tag relations data (Please dump into a separate database)- CREATE TABLE IF NOT EXISTS `tutors_tag_relations` ( `id_tag_rel` int(10) NOT NULL AUTO_INCREMENT, `id_tag` int(10) unsigned NOT NULL DEFAULT '0', `id_tutor` int(10) DEFAULT NULL, PRIMARY KEY (`id_tag_rel`), KEY `All_Tag_Relations_FKIndex1` (`id_tag`), KEY `id_tag` (`id_tag`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `tutors_tag_relations` (`id_tag_rel`, `id_tag`, `id_tutor`) VALUES (1, 1, 1), (2, 2, 1), (3, 6, 2), (4, 7, 2); CREATE TABLE IF NOT EXISTS `webclasses_tag_relations` ( `id_tag_rel` int(10) NOT NULL AUTO_INCREMENT, `id_tag` int(10) unsigned NOT NULL DEFAULT '0', `id_tutor` int(10) DEFAULT NULL, `id_wc` int(10) DEFAULT NULL, PRIMARY KEY (`id_tag_rel`), KEY `webclasses_Tag_Relations_FKIndex1` (`id_tag`), KEY `id_wc` (`id_wc`), KEY `id_tag` (`id_tag`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `webclasses_tag_relations` (`id_tag_rel`, `id_tag`, `id_tutor`, `id_wc`) VALUES (1, 3, 1, 1), (2, 4, 1, 1), (3, 5, 2, 2), (4, 4, 2, 2); CREATE TABLE IF NOT EXISTS `tags` ( `id_tag` int(10) unsigned NOT NULL AUTO_INCREMENT, `tag` varchar(255) DEFAULT NULL, PRIMARY KEY (`id_tag`), UNIQUE KEY `tag` (`tag`), KEY `id_tag` (`id_tag`), KEY `tag_2` (`tag`), KEY `tag_3` (`tag`), KEY `tag_4` (`tag`), FULLTEXT KEY `tag_5` (`tag`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; INSERT INTO `tags` (`id_tag`, `tag`) VALUES (1, 'Sandeepan'), (2, 'Nath'), (3, 'first'), (4, 'class'), (5, 'new'), (6, 'Bob'), (7, 'Cratchit'); CREATE TABLE IF NOT EXISTS `all_tag_relations` ( `id_tag_rel` int(10) NOT NULL AUTO_INCREMENT, `id_tag` int(10) unsigned NOT NULL DEFAULT '0', `id_tutor` int(10) DEFAULT NULL, `id_wc` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id_tag_rel`), KEY `All_Tag_Relations_FKIndex1` (`id_tag`), KEY `id_wc` (`id_wc`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; insert into All_Tag_Relations select NULL,id_tag,id_tutor,NULL from Tutors_Tag_Relations; insert into All_Tag_Relations select NULL,id_tag,id_tutor,id_wc from Webclasses_Tag_Relations; Here you can see how easily tutor first name can be edited only in one place. But search has become really difficult, so on being advised to use a Temporary table, I am creating one at every search request, then dumping all the necessary data and then searching from it, I am creating this All_Tag_Relations table at search run time. Here I am just dumping all the data from the two tables Tutors_Tag_Relations and Webclasses_Tag_Relations. But, I am still not able to get classes if I search with tutor name This is the query which searches "first class". Running them on both the systems shows correct results (returns the class with id_wc = 1). SELECT wtagrels.id_wc,SUM(DISTINCT( wtagrels.id_tag =3)) AS key_1_total_matches, SUM(DISTINCT( wtagrels.id_tag =4)) AS key_2_total_matches FROM all_tag_relations AS wtagrels WHERE ( wtagrels.id_tag =3 OR wtagrels.id_tag =4 ) GROUP BY wtagrels.id_wc HAVING key_1_total_matches = 1 AND key_2_total_matches = 1 LIMIT 0, 20 But, searching for "Sandeepan class" works only with the 1st system Here is the query which searches "Sandeepan class" SELECT wtagrels.id_wc,SUM(DISTINCT( wtagrels.id_tag =1)) AS key_1_total_matches, SUM(DISTINCT( wtagrels.id_tag =4)) AS key_2_total_matches FROM all_tag_relations AS wtagrels WHERE ( wtagrels.id_tag =1 OR wtagrels.id_tag =4 ) GROUP BY wtagrels.id_wc HAVING key_1_total_matches = 1 AND key_2_total_matches = 1 LIMIT 0, 20 Can anybody alter this query and somehow do a proper join or something to get correct results. That solves my problem in a nice way. As you can figure out, the reason why it does not work in system 2 is that in system 1, for every class, one additional tag relation linking class and tutor name is present. e.g. for class first class, (records with id_tag_rel 3 and 4) which returns the class on searching with tutor name. So, you see the trade-off between the search and profile edition difficulty with the two systems. How do I overcome both. I have to reach a conclusion soon. So far my reasoning is it is definitely not good from a code maintainability point of view to follow the single tag rel table structure of system one, because in a real system while editing a field like "tutor qualifications", there can be as many records in tag rels table as there are words in qualification of a tutor (one word in a field = one tag relation). Now suppose a tutor has 100 classes. When he edits his qualification, all the tag rel rows corresponding to him are deleted and then as many copies are to be created (as per the new qualification data) as there are classes. This becomes particularly difficult if later more searcheable fields are added. The code cannot be robust. Is the best solution to follow system 2 (edition has to be in one table - no extra work for each and every class) and somehow re-create the all_tag_relations table like system 1 (from the tables tutor_tag_relations and webclasses_tag_relations), creating the extra tutor tag rels for each and every class by a tutor (which is currently missing in system 2's temporary all_tag_relations table). That would be a time consuming logic script. I doubt that table can be recreated without resorting to PHP sript (mysql alone cannot do that). But the problem is that running all this at search time will make search definitely slow. So, how do such systems work? How are such situations handled? I thought about we can run a cron which initiates that PHP script, say every 1 minute and replaces the existing all_tag_relations table as per new tag rels from tutor_tag_relations and webclasses_tag_relations (replaces means creates a new table, deletes the original and renames the new one as all_tag_relations, otherwise search won't work during that period- or is there any better way to that?). Anyway, the result would be that any changes by tutors will reflect in search in the next 1 minute and not immediately. An alternateve would be to initate that PHP script every time a tutor edits his profile. But here again, since many users may edit their profiles concurrently, will the creation of so many tables be a burden and can mysql make the server slow? Any help would be appreciated and working solution will be accepted as answer. Thanks, Sandeepan

    Read the article

  • Which databases support parallel processing across multiple servers?

    - by David
    I need a database engine that can utilize multiple servers for processing a single SQL query in parallel. So far I know that this is possible with the some engines, though none of them are feasible for me either because of pricing or missing features. The engines currently known to me are: MS SQL (enterprise) DB2 (enterprise) Oracle (enterprise) GridSQL Greenplum Which other engines have this feature? Do you have any experience with using this feature? Edit: I have now proposed a method for creating one myself. Any input is welcome. Edit: I have found another one: Informix Extended Parallel Server

    Read the article

  • Website Maintenance to Keep your Site Going At Top

    Having a website with professional design with all other elements in place is surely good thing in itself, but unlike other things like TV, air conditioner, computers, etc websites also demand mainte... [Author: Alan Smith - Web Design and Development - June 13, 2010]

    Read the article

  • Reasons for Conducting Keyword Research

    For successful SEO usage of proper keywords/key phrases is needed. Many webmasters lay extra importance to keyword research for every given article of web content. But most of the people new to this ... [Author: Alan Smith - Web Design and Development - June 13, 2010]

    Read the article

  • Benefits of PSD to HTML Service? For Whom and How

    With the advent of Internet and e-industry, most of the companies create website and hire web development professionals. And it is also true that the process of converting a design into web pages is ... [Author: Manish Rawat - Web Design and Development - June 13, 2010]

    Read the article

  • Cyber Stalkers Often Escalate to Sexual Predators

    Many individuals do not take cyber stalkers seriously because they do not consider this problem to be very serious. After all what can a person do to you through words on a computer screen? Because o... [Author: Ed Opperman - Computers and Internet - June 13, 2010]

    Read the article

  • Recruitment Software for a Growing Business

    If you are interested in improving your company?s recruitment process and making it more efficient then follow the example set by some of the world?s largest organizations and utilise the latest tech... [Author: Andrea Watkins - Computers and Internet - June 13, 2010]

    Read the article

  • E-commerce and Online Purchase Success

    The advent of the Internet technology opens another yet effective way of buying products. E-commerce websites are growing exponentially ? businesses understand its power for income and profit generat... [Author: David white - Computers and Internet - June 13, 2010]

    Read the article

  • yiic shell: failed to perform 'crud'

    - by ufw
    Debian Squeeze, PHP 5.3.2-1, Yii 1.1.2, PHP $path to php is /usr/bin/php, permissions are '777'. When I try to run 'crud Test' in yii shell, I get the following error message: PHP Warning: include(/var/www/test/protected/models/Test.php): failed to open stream: No such file or directory in /var/www/yii/framework/YiiBase.php on line 335 PHP Warning: include(): Failed opening '/var/www/test/protected/models/Test.php' for inclusion (include_path='.:/var/www/test/protected/components:/var/www/test/protected/models:/usr/share/php:/usr/share/pear') in /var/www/yii/framework/YiiBase.php on line 335 PHP Fatal error: Class 'Test' not found in /var/www/yii/framework/db/ar/CActiveRecord.php on line 341

    Read the article

  • What is the PastryKit Framework?

    - by Kerrick
    I'm trying to find any information I can on the PastryKit Javascript Framework. It appears to be in use on the iPhone User Guide that is displayed on the iPhone itself in Mobile Safari, but I cannot find any documentation or API. If you want to see it in action, open Safari 4, set your user agent to iPhone 3 (In the Develop menu) and check out the guide. Overall, it seems to be a way to write an HTML/CSS/Javascript application that acts like a native iPhone app. When it comes to Javascript, I used the JS Beautifier on (what I assume to be) the framework file and it was over 3,400 lines! Beautified, (again what I assume to be) their implementation of it was over 1,200 lines. On the CSS side, I used Clean CSS on (again what I assume to be) the framework CSS, and it came out to over 700 lines. Their implementation was shy of 500. Does anybody have, or know where to find, any information, documentation, or APIs on PastryKit? Or, can anybody figure out how to implement it?

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >