Search Results

Search found 1006 results on 41 pages for 'istream iterator'.

Page 24/41 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • What design pattern shall I use in this question?

    - by iyad al aqel
    To be frank, this is a homework question, so I'll tell you my opinion. Can you let me know my mistakes rather than giving me the solution? This is the question : Assume a restaurant that only offers the following two types of meals: (a) a full meal and (b)an economic meal. The full meal consists of the following food items and is served in the following order: 1. Appetizer 2. Drink 3. Main dish 4. Dessert Meanwhile the economic meal consists of the following food items and is served in the following order: 1. Drink 2. Main dish Identify the most appropriate design pattern that can be used to allow a customer to only order using one of the two types of meals provided and that the meal components must be served in the given order. I'm confused between the Factory and the Iterator and using them both together. Using the factory Pattern we can create the two meals full and economic and provide the user with with a base object class that will decide upon. But how can we enforce the ordering of the elements, I thought of using the iterator along that will iterate through the the composite of the two created factories sort of speak. What do you think?

    Read the article

  • Why doesn't java.util.Set have get(int index)?

    - by Marty Pitt
    I'm sure there's a good reason, but could someone please explain why the java.util.Set interface lacks get(int Index), or any similar get() method? It seems that sets are great for putting things into, but I can't find an elegant way of retrieving a single item from it. If I know I want the first item, I can use set.iterator().next(), but otherwise it seems I have to cast to an Array to retrieve an item at a specific index? What are the appropriate ways of retrieving data from a set? (other than using an iterator) I'm sure the fact that it's excluded from the API means there's a good reason for not doing this -- could someone please enlighten me? EDIT: Some extremely great answers here, and a few saying "more context". The specific scneario was a dbUnit test, where I could reasonalby assert that the returned set from a query had only 1 item, and I was trying to access that item. However, the question is more valid without the scenario, as it remains more focussed : What's the difference between set & list. Thanks to all for the fantastic answers below.

    Read the article

  • can a webservice load jars during run time

    - by KItis
    I have created a simple web-service using Java. i want to load jars related to web-service during runtime. I have done this task for normal Java application. there what I did was JarFile jar = new JarFile(f.getPath()); final Manifest manifest = jar.getManifest(); final Attributes mattr = manifest.getMainAttributes(); // Read the manifset in jar files and get the Name attribute // whare it specified the class that need to load //for (Object a : mattr.keySet()) { for (Iterator iter = mattr.keySet().iterator(); iter.hasNext();) { Object obj = (Object)iter.next(); if ("ServiceName".equals(obj.toString())) className = mattr.getValue((Name) obj); //System.out.println(className); } /* * Create the jar class loader and use the first argument passed * in from the command line as the jar file to use. */ JarClassLoader jarLoader = new JarClassLoader(f.getPath()); /* Load the class from the jar file and resolve it. */ Class c = jarLoader.loadClass(className, true); My problem is can I put jars that need to be loaded during run time in to separate folder rather than putting in to WEBINF folder. do i have to put jars both in axis and web-application. thanks in advance for any contribution for this question.

    Read the article

  • Implementing list position locator in C++?

    - by jfrazier
    I am writing a basic Graph API in C++ (I know libraries already exist, but I am doing it for the practice/experience). The structure is basically that of an adjacency list representation. So there are Vertex objects and Edge objects, and the Graph class contains: list<Vertex *> vertexList list<Edge *> edgeList Each Edge object has two Vertex* members representing its endpoints, and each Vertex object has a list of Edge* members representing the edges incident to the Vertex. All this is quite standard, but here is my problem. I want to be able to implement deletion of Edges and Vertices in constant time, so for example each Vertex object should have a Locator member that points to the position of its Vertex* in the vertexList. The way I first implemented this was by saving a list::iterator, as follows: vertexList.push_back(v); v->locator = --vertexList.end(); Then if I need to delete this vertex later, then rather than searching the whole vertexList for its pointer, I can call: vertexList.erase(v->locator); This works fine at first, but it seems that if enough changes (deletions) are made to the list, the iterators will become out-of-date and I get all sorts of iterator errors at runtime. This seems strange for a linked list, because it doesn't seem like you should ever need to re-allocate the remaining members of the list after deletions, but maybe the STL does this to optimize by keeping memory somewhat contiguous? In any case, I would appreciate it if anyone has any insight as to why this happens. Is there a standard way in C++ to implement a locator that will keep track of an element's position in a list without becoming obsolete? Much thanks, Jeff

    Read the article

  • Python unicode search not giving correct answer

    - by user1318912
    I am trying to search hindi words contained one line per file in file-1 and find them in lines in file-2. I have to print the line numbers with the number of words found. This is the code: import codecs hypernyms = codecs.open("hindi_hypernym.txt", "r", "utf-8").readlines() words = codecs.open("hypernyms_en2hi.txt", "r", "utf-8").readlines() count_arr = [] for counter, line in enumerate(hypernyms): count_arr.append(0) for word in words: if line.find(word) >=0: count_arr[counter] +=1 for iterator, count in enumerate(count_arr): if count>0: print iterator, ' ', count This is finding some words, but ignoring some others The input files are: File-1: ???? ??????? File-2: ???????, ????-???? ?????-???, ?????-???, ?????_???, ?????_??? ????_????, ????-????, ???????_???? ????-???? This gives output: 0 1 3 1 Clearly, it is ignoring ??????? and searching for ???? only. I have tried with other inputs as well. It only searches for one word. Any idea how to correct this?

    Read the article

  • Pushing a vector into an vector

    - by Sunil
    I have a 2d vector typedef vector <double> record_t; typedef vector <record_t> data_t; data_t data; So my 2d vector is data here. It has elements like say, 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 Now I want to insert these elements into another 2d vector std::vector< vector<double> > window; So what I did was to create an iterator for traversing through the rows of data and pushing it into windowlike std::vector< std::vector<double> >::iterator data_it; for (data_it = data.begin() ; data_it != data.end() ; ++data_it) window.push_back ( *data_it ); Can anybody tell me where I'm wrong or suggest a way to do this ? Thanks

    Read the article

  • Compare Long values Struts2

    - by Marquinio
    Hi everyone I'm trying to compare two values using struts2 s:if tag but its not working. If I hardcode the values it works but I want it to be dynamic. The variable stringValue is of type String. The variable currentLongValue is of type Long. <s:set var="stringValue" value="order"/> <s:iterator value="listTest"> <s:set var="currentLongValue" value="value"/> <s:if test="#currentLongValue.toString() == #stringValue" > //Do something </s:if> <s:else> //Do something else </s:else> </s:iterator> For the s:if I have tried toString and also the equals(). It only works if I hardcode the values. Example: <s:if test="#currentLongValue == 1234"> Any clues? Thank you.

    Read the article

  • How can I go through a Set in JSP? (Hibernate Associations)

    - by Parris
    Hi All, So I am pretty new to JSP. I have tried this a few ways. Ways that would make sense in PHP or automagicy frameworks... I am probably thinking too much in fact... I have a hibernate one to many association. That is class x has many of class y. In class x's view.jsp. I would like to grab all of class y, where the foreign key of y matches the primary key of x and display them. It seems that hibernate properly puts this stuff into a set. Now, the question is how can I iterate through this set and then output it's contents... I am kind of stumped here. I tried to write a scriptlet, <% java.util.Iterator iter = aBean.getYs().iter(); // aBeans is the bean name // getYs would return the set and iter would return an iterator for the set while(iter.hasNext) { model.X a = new iter.next() %> <h1><%=a.getTitle()%></h1> <% } %> It would seem that that sort of thing should work? Hmmmmmm

    Read the article

  • JSP/Struts2/Hibernate: loop through a self-referencing table.

    - by TBW
    Hello everyone, Let's say we have a self-referencing table called PERSON, with the following columns: ID, PARENT, where PARENT is a foreign key to the ID column of another element in the PERSON table. Of course, many persons can have the same parent. I use Hibernate 3 in lazy fetching mode to deal with the database. Hibernate fetches a person element from the database, which is then put in the ValueStack by the Struts2 action, to be used on the result JSP page. Now the question is : In JSP, how can I do to display all the child (and the child's child, and so on, like a family tree) of this person element? Of course, for the n+1 children I can use the < s:iterator tag over the person.person. I can also nest another < s:iterator tag over person.person.person to get the n+2 children. But what if I want to do this in an automated manner, up to the last n+p child, displaying in the process all the children of all the n+1..n+p elements? I hope I have been clear enough. Thank you all for your time. -- TBW.

    Read the article

  • Parse large XML file w/ script or use BioPython API ?

    - by jeremy04
    Hey guys this is my first question on here. I'm trying to make a local copy of the UniprotKB in SQL. The UniprotKB is 2.1GB, and it comes in XML and a special text format used by SwissProt Here are my options: 1) Use a SAX parser (XML) - I chose Ruby, and Nokogiri. I started writing the parser, but my initial reaction: how would I map the XML schema to the SAX parser? 2) BioPython - I already have BioSQL/Biopython installed, which literally created my SQL schema for me, and I was able to successfully insert one SwissProt/Uniprot txt file into the database. I'm running it right now (crosses fingers) on the entire 2.1gb. Here is the code I'm running: from Bio import SeqIO from BioSQL import BioSeqDatabase from Bio import SwissProt server = BioSeqDatabase.open_database(driver = "MySQLdb", user = "root", passwd = "", host="localhost", db = "bioseqdb") db = server["uniprot"] iterator = SeqIO.parse(open("/path/to/uniprot_sprot.dat", "r"), "swiss") db.load(iterator) server.commit() Edit: it's now crashing because the transactions are getting locked (since the tables are Innodb) Error Number: 1205 Lock wait timeout exceeded; try restarting transaction. I'm using MySQL version: 5.1.43 Should I switch my database to Postgrelsql ?

    Read the article

  • This code is not submitting to a form? Why

    - by Ankur
    Since I am using get I expect to see the submitted values appended to the queryString but instead all I see is the URL of the servlet being called with nothing added at the end. <form id="editClassList" name="editClassList" method="get" action="EditClassList"> <% HashMap<Integer,String> classes = new HashMap<Integer,String>(); classes = (HashMap<Integer,String>) request.getAttribute("classes"); %> <% if(classes.size()==0){ %> <label><input class="small-link" type="text" id="add-this-class" size="42" value="" /></label> <% } %> <% Set<Integer> classIds = new HashSet<Integer>(); classIds = classes.keySet(); Iterator<Integer> itr = classIds.iterator(); while(itr.hasNext()){ int nextId = (Integer)itr.next(); %> <label><input class="small-link" type="text" id="<% out.print(nextId); %>" size="42" value="<% out.print(classes.get(nextId)); %>" /> </label> <img id="add-class" src="images/add.png" width="16" height="16" /><br /> <label><input class="small-link" type="text" id="class-to-add" size="42" value="" /></label> <% } %> <label><input type="submit" id="save-class-btn" value="Save Class(es)" /></label> </form>

    Read the article

  • Item in multiple lists

    - by Evan Teran
    So I have some legacy code which I would love to use more modern techniques. But I fear that given the way that things are designed, it is a non-option. The core issue is that often a node is in more than one list at a time. Something like this: struct T { T *next_1; T *prev_1; T *next_2; T *prev_2; int value; }; this allows the core have a single object of type T be allocated and inserted into 2 doubly linked lists, nice and efficient. Obviously I could just have 2 std::list<T*>'s and just insert the object into both...but there is one thing which would be way less efficient...removal. Often the code needs to "destroy" an object of type T and this includes removing the element from all lists. This is nice because given a T* the code can remove that object from all lists it exists in. With something like a std::list I would need to search for the object to get an iterator, then remove that (I can't just pass around an iterator because it is in several lists). Is there a nice c++-ish solution to this, or is the manually rolled way the best way? I have a feeling the manually rolled way is the answer, but I figured I'd ask.

    Read the article

  • using yield in C# like I would in Ruby

    - by Sarah Vessels
    Besides just using yield for iterators in Ruby, I also use it to pass control briefly back to the caller before resuming control in the called method. What I want to do in C# is similar. In a test class, I want to get a connection instance, create another variable instance that uses that connection, then pass the variable to the calling method so it can be fiddled with. I then want control to return to the called method so that the connection can be disposed. I guess I'm wanting a block/closure like in Ruby. Here's the general idea: private static MyThing getThing() { using (var connection = new Connection()) { yield return new MyThing(connection); } } [TestMethod] public void MyTest1() { // call getThing(), use yielded MyThing, control returns to getThing() // for disposal } [TestMethod] public void MyTest2() { // call getThing(), use yielded MyThing, control returns to getThing() // for disposal } ... This doesn't work in C#; ReSharper tells me that the body of getThing cannot be an iterator block because MyThing is not an iterator interface type. That's definitely true, but I don't want to iterate through some list. I'm guessing I shouldn't use yield if I'm not working with iterators. Any idea how I can achieve this block/closure thing in C# so I don't have to wrap my code in MyTest1, MyTest2, ... with the code in getThing()'s body?

    Read the article

  • Java NullPointerException In the constructor's class

    - by AndreaF
    I have made a Java class where I have defined a constructor and some methods but I get a NullPointer Exception, and I don't know how I could fix It. public class Job { String idJob; int time; int timeRun; Job j1; List<Job> startBeforeStart; List<Job> restricted; Job(String idJob, int time){ this.idJob=idJob; this.time=time; } public boolean isRestricted() { return restricted.size() != 0; } public void startsBeforeStartOf(Job job){ startBeforeStart.add(job); job.restricted.add(this); } public void startsAfterStartOf(Job job){ job.startsBeforeStartOf(this); } public void checkRestrictions(){ if (!isRestricted()){ System.out.println("+\n"); } else{ Iterator<Job> itR = restricted.iterator(); while(itR.hasNext()){ Job j1 = itR.next(); if(time>timeRun){ System.out.println("-\n"); time--; } else { restricted.remove(j1); } } } } @Override public boolean equals(Object obj) { return obj instanceof Job && ((Job) obj).idJob.equals(idJob); } public void run() { timeRun++; } } PS Looking in a forum a user says that to fix the error I should make an ArrayList inside the constructor (without modify the received parameters that should remain String id and int time), but I haven't understand what He mean.

    Read the article

  • How to get the set of beans that are to be created in Spring?

    - by cyborg
    So here's the scenario: I have a Spring XML configuration with some lazy-beans, some not lazy-beans and some beans that depend on other beans. Eventually Spring will resolve all this so that only the beans that are meant to be created are created. The question: how can I programmatically tell what this set is? When I use context.getBean(name) that initializes the bean. BeanDefinition.isLazyInit() will only tell me how I defined the bean. Any other ideas? ETA: In DefaultListableBeanFactory: public void preInstantiateSingletons() throws BeansException { if (this.logger.isInfoEnabled()) { this.logger.info("Pre-instantiating singletons in " + this); } synchronized (this.beanDefinitionMap) { for (Iterator it = this.beanDefinitionNames.iterator(); it.hasNext();) { String beanName = (String) it.next(); RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName); if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) { if (isFactoryBean(beanName)) { FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName); if (factory instanceof SmartFactoryBean && ((SmartFactoryBean) factory).isEagerInit()) { getBean(beanName); } } else { getBean(beanName); } } } } } The set of instantiable beans is initialized. When initializing this set any beans not in this set referenced by this set will also be created. From looking through the source it does not look like there's going to be any easy way to answer my question.

    Read the article

  • how to display values of an arraylist defined in servlet using ajax call

    - by veena123
    can anyone please help me with below code servlet: below servlet is for statically defining an array. import java.io.; import javax.servlet.; import javax.servlet.http.; import java.util.; public class SampleAjax extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException { response.setContentType("text/html"); string plociyno = "abd1234"; PrintWriter pw = response.getWriter(); if (policyno.equals("abc1234")) { List dataList= new ArrayList(); dataList.add("automated refund possible"); request.setAttribute("data",dataList); RequestDispatcher dispatcher = request.getRequestDispatcher("refund.jsp"); if (dispatcher != null){ dispatcher.forward(request, response); } } } and my jsp: jsp for displayng the values of the arraylist in a table.... i want to do the same thing but using ajax.... please help <html <body><table id= "table" border="0" width="303"> <tr> <td width="250"><b>Your Policy Refund Details is:</b></td> </tr> <%Iterator itr; %> <% ArrayList refund= (ArrayList)request.getAttribute("data"); if(refund != null){ for(itr=refund.iterator(); itr.hasNext();){ %> <tr> <td><%=itr.next()%></td> </tr> <%}}%> </table> </body> </html> how can i display this arraylist values using ajax??? please help

    Read the article

  • How to write a custom predicate for multi_index_containder with composite_key?

    - by Titan
    I googled and searched in the boost's man, but didn't find any examples. May be it's a stupid question...anyway. So we have the famous phonebook from the man: typedef multi_index_container< phonebook_entry, indexed_by< ordered_non_unique< composite_key< phonebook_entry, member<phonebook_entry,std::string,&phonebook_entry::family_name>, member<phonebook_entry,std::string,&phonebook_entry::given_name> >, composite_key_compare< std::less<std::string>, // family names sorted as by default std::greater<std::string> // given names reversed > >, ordered_unique< member<phonebook_entry,std::string,&phonebook_entry::phone_number> > > > phonebook; phonebook pb; ... // look for all Whites std::pair<phonebook::iterator,phonebook::iterator> p= pb.equal_range(boost::make_tuple("White"), my_custom_comp()); How should my_custom_comp() look like? I mean it's clear for me then it takes boost::multi_index::composite_key_result<CompositeKey> as an argumen (due to compilation errors :) ), but what is CompositeKey in that particular case? struct my_custom_comp { bool operator()( ?? boost::multi_index::composite_key_result<CompositeKey> ?? ) const { return blah_blah_blah; } }; Thanks in advance.

    Read the article

  • Determining if an unordered vector<T> has all unique elements

    - by Hooked
    Profiling my cpu-bound code has suggested I that spend a long time checking to see if a container contains completely unique elements. Assuming that I have some large container of unsorted elements (with < and = defined), I have two ideas on how this might be done: The first using a set: template <class T> bool is_unique(vector<T> X) { set<T> Y(X.begin(), X.end()); return X.size() == Y.size(); } The second looping over the elements: template <class T> bool is_unique2(vector<T> X) { typename vector<T>::iterator i,j; for(i=X.begin();i!=X.end();++i) { for(j=i+1;j!=X.end();++j) { if(*i == *j) return 0; } } return 1; } I've tested them the best I can, and from what I can gather from reading the documentation about STL, the answer is (as usual), it depends. I think that in the first case, if all the elements are unique it is very quick, but if there is a large degeneracy the operation seems to take O(N^2) time. For the nested iterator approach the opposite seems to be true, it is lighting fast if X[0]==X[1] but takes (understandably) O(N^2) time if all the elements are unique. Is there a better way to do this, perhaps a STL algorithm built for this very purpose? If not, are there any suggestions eek out a bit more efficiency?

    Read the article

  • "Forced constness" in std::map<std::vector<int>,double> > ?

    - by Peter Jansson
    Consider this program: #include <map> #include <vector> typedef std::vector<int> IntVector; typedef std::map<IntVector,double> Map; void foo(Map& m,const IntVector& v) { Map::iterator i = m.find(v); i->first.push_back(10); }; int main() { Map m; IntVector v(10,10); foo(m,v); return 0; } Using g++ 4.4.0, I get his compilation error: test.cpp: In function 'void foo(Map&, const IntVector&)': test.cpp:8: error: passing 'const std::vector<int, std::allocator<int> >' as 'this' argument of 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = int, _Alloc = std::allocator<int>]' discards qualifiers I would expect this error if I was using Map::const_iterator inside foo but not using a non-const iterator. What am I missing, why do I get this error?

    Read the article

  • What is the difference between these two linq implementations?

    - by Mahesh Velaga
    I was going through Jon Skeet's Reimplemnting Linq to Objects series. In the implementation of where article, I found the following snippets, but I don't get what is the advantage that we are gettting by splitting the original method into two. Original Method: // Naive validation - broken! public static IEnumerable<TSource> Where<TSource>( this IEnumerable<TSource> source, Func<TSource, bool> predicate) { if (source == null) { throw new ArgumentNullException("source"); } if (predicate == null) { throw new ArgumentNullException("predicate"); } foreach (TSource item in source) { if (predicate(item)) { yield return item; } } } Refactored Method: public static IEnumerable<TSource> Where<TSource>( this IEnumerable<TSource> source, Func<TSource, bool> predicate) { if (source == null) { throw new ArgumentNullException("source"); } if (predicate == null) { throw new ArgumentNullException("predicate"); } return WhereImpl(source, predicate); } private static IEnumerable<TSource> WhereImpl<TSource>( this IEnumerable<TSource> source, Func<TSource, bool> predicate) { foreach (TSource item in source) { if (predicate(item)) { yield return item; } } } Jon says - Its for eager validation and then defferring for the rest of the part. But, I don't get it. Could some one please explain it in a little more detail, whats the difference between these 2 functions and why will the validations be performed in one and not in the other eagerly? Conclusion/Solution: I got confused due to my lack of understanding on which functions are determined to be iterator-generators. I assumed that, it is based on signature of a method like IEnumerable<T>. But, based on the answers, now I get it, a method is an iterator-generator if it uses yield statements.

    Read the article

  • Looping over commits for a file with jGit

    - by Andy Jarrett
    I've managed to get to grips with the basics of jGit file in terms of connecting to a repos and adding, commiting, and even looping of the commit messages for the files. File gitDir = new File("/Users/myname/Sites/helloworld/.git"); RepositoryBuilder builder = new RepositoryBuilder(); Repository repository; repository = builder.setGitDir(gitDir).readEnvironment() .findGitDir().build(); Git git = new Git(repository); RevWalk walk = new RevWalk(repository); RevCommit commit = null; // Add all files // AddCommand add = git.add(); // add.addFilepattern(".").call(); // Commit them // CommitCommand commit = git.commit(); // commit.setMessage("Commiting from java").call(); Iterable<RevCommit> logs = git.log().call(); Iterator<RevCommit> i = logs.iterator(); while (i.hasNext()) { commit = walk.parseCommit( i.next() ); System.out.println( commit.getFullMessage() ); } What I want to do next is be able to get all the commit message for a single file and then be able revert the single file back to a specific reference/point in time.

    Read the article

  • Determing if an unordered vector<T> has all unique elements

    - by Hooked
    Profiling my cpu-bound code has suggested I that spend a long time checking to see if a container contains completely unique elements. Assuming that I have some large container of unsorted elements (with < and = defined), I have two ideas on how this might be done: The first using a set: template <class T> bool is_unique(vector<T> X) { set<T> Y(X.begin(), X.end()); return X.size() == Y.size(); } The second looping over the elements: template <class T> bool is_unique2(vector<T> X) { typename vector<T>::iterator i,j; for(i=X.begin();i!=X.end();++i) { for(j=i+1;j!=X.end();++j) { if(*i == *j) return 0; } } return 1; } I've tested them the best I can, and from what I can gather from reading the documentation about STL, the answer is (as usual), it depends. I think that in the first case, if all the elements are unique it is very quick, but if there is a large degeneracy the operation seems to take O(N^2) time. For the nested iterator approach the opposite seems to be true, it is lighting fast if X[0]==X[1] but takes (understandably) O(N^2) time if all the elements are unique. Is there a better way to do this, perhaps a STL algorithm built for this very purpose? If not, are there any suggestions eek out a bit more efficiency?

    Read the article

  • Error in django using Apache & mod_wsgi

    - by Ignacio
    Hey, I've been doing some changes to my django develpment env, as some of you suggested. So far I've managed to configure and run it successfully with postgres. Now I'm trying to run the app using apache2 and mod_wsgi, but I ran into this little problem after I followed the guidelines from the django docs. When I access localhost/myapp/tasks this error raises: Request Method: GET Request URL: http://localhost/myapp/tasks/ Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: argument 1 must be a string or unicode object Original Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/local/lib/python2.6/dist-packages/django/template/defaulttags.py", line 126, in render len_values = len(values) File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 81, in __len__ self._result_cache = list(self.iterator()) File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 238, in iterator for row in self.query.results_iter(): File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 287, in results_iter for rows in self.execute_sql(MULTI): File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 2369, in execute_sql cursor.execute(sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) TypeError: argument 1 must be a string or unicode object ... ... ... And then it highlights a {% for t in tasks %} template tag, like the source of the problem is there, but it worked fine on the built-in server. The view associated with that page is really simple, just fetch all Task objects. And the template just displays them on a table. Also, some pages get rendered ok. Don't want to fill this Question with code, so if you need some more info I'd be glad to provide it. Thanks

    Read the article

  • iterators to range of elements in a vector whose attributes have specific value

    - by user1801173
    I have a vector of objects and I want to return the range of elements whose attribute have a specific value. This is the structure: class A { public: std::vector<B*> vec_; pair<vector<B*>::iterator, vector<B*>::iterator> getElements(unsigned int attr_val); unsigned int name() { return name_; } private: unsigned int name_; }; class B { public: unsigned int attr() { return attr_; } A* source() { return source_; } B* dest() { return dest_; } private: A* source_; B* dest_; unsigned int attr_; }; The vector vec_; is already sorted by attr_ and dest_-name() (in that order). Now I want to return all elements, whose attr_ is equal to attr_val. What is the appropriate stl algorithm (or is there even a vector member function?) to implement getElements(unsigned int attr_val) ? Thanks for help.

    Read the article

  • C++ map to track when the end of map is reached

    - by eNetik
    Currently I have a map that prints out the following map<string, map<int,int> > mapper; map<int,int>::iterator inner; map<string, map<int,int> >::iterator outer; for(outer = mapper.begin(); outer != mapper.end(); outer++){ cout<<outer->first<<": "; for(inner = outer->second.begin(); inner != outer->second.end(); inner++){ cout<<inner->first<<","<<inner->second<<","; } } As of now this prints out the following stringone: 1,2,3,4,6,7,8, stringtwo: 3,5,6,7, stringthree: 2,3,4,5, What i want it to print out is stringone: 1,2,3,4,6,7,8 stringtwo: 3,5,6,7 stringthree: 2,3,4,5 how can i check for the end of the map inside my inner map? Any help would be appreciated Thank you

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >