Search Results

Search found 908 results on 37 pages for 'iterator'.

Page 12/37 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • JSP Iterating over a map of a list when the value might be null

    - by Brian Hoover
    How do I clear the value from the stack of a s:iterator? I'm trying to iterator over a TreeMultimap with a structure like: TreeMultimap<person, lineItems> persons; Using something like: <s:iterator value="attendeesForParticipantTypeEvents.asMap()"> <div> <s:property value="key.name" /><br /> <s:iterator id="currentSku" value="value"> <s:property value="currentSku.name" /><br /> </s:iterator> </div> </s:iterator> This works fine, except when the treeMultimap has null for lineItems, then it's taking the value from the previous iteration. So, a structure like: persons = {{"Person1",["Line1","line2"]}, {"Person2",["Line3","line4"]}, {"Person2",null}} Renders as: <div> Person1<br /> Line1<br /> Line2<br /> </div> <div> Person2<br /> Line3<br /> Line4<br /> </div> <div> Person3<br /> Line3<br /> Line4<br /> </div> Which seems to indicate that the value isn't being cleared on each iterator. What do I need to do to handle the case where value might be null? Thanks for your help

    Read the article

  • C++: Trouble with dependent types in templates

    - by Rosarch
    I'm having trouble with templates and dependent types: namespace Utils { void PrintLine(const string& line, int tabLevel = 0); string getTabs(int tabLevel); template<class result_t, class Predicate> set<result_t> findAll_if(typename set<result_t>::iterator begin, set<result_t>::iterator end, Predicate pred) // warning C4346 { set<result_t> result; return findAll_if_rec(begin, end, pred, result); } } namespace detail { template<class result_t, class Predicate> set<result_t> findAll_if_rec(set<result_t>::iterator begin, set<result_t>::iterator end, Predicate pred, set<result_t> result) { typename set<result_t>::iterator nextResultElem = find_if(begin, end, pred); if (nextResultElem == end) { return result; } result.add(*nextResultElem); return findAll_if_rec(++nextResultElem, end, pred, result); } } Compiler complaints, from the location noted above: warning C4346: 'std::set<result_t>::iterator' : dependent name is not a type. prefix with 'typename' to indicate a type error C2061: syntax error : identifier 'iterator' What am I doing wrong?

    Read the article

  • C# powershell output reader iterator getting modified when pipeline closed and disposed.

    - by scope-creep
    Hello, I'm calling a powershell script from C#. The script is pretty small and is "gps;$host.SetShouldExit(9)", which list process, and then send back an exit code to be captured by the PSHost object. The problem I have is when the pipeline has been stopped and disposed, the output reader PSHost collection still seems to be written to, and is filling up. So when I try and copy it to my own output object, it craps out with a OutOfMemoryException when I try to iterate over it. Sometimes it will except with a Collection was modified message. Here is the code. private void ProcessAndExecuteBlock(ScriptBlock Block) { Collection<PSObject> PSCollection = new Collection<PSObject>(); Collection<Object> PSErrorCollection = new Collection<Object>(); Boolean Error = false; int ExitCode=0; //Send for exection. ExecuteScript(Block.Script); // Process the waithandles. while (PExecutor.PLine.PipelineStateInfo.State == PipelineState.Running) { // Wait for either error or data waithandle. switch (WaitHandle.WaitAny(PExecutor.Hand)) { // Data case 0: Collection<PSObject> data = PExecutor.PLine.Output.NonBlockingRead(); if (data.Count > 0) { for (int cnt = 0; cnt <= (data.Count-1); cnt++) { PSCollection.Add(data[cnt]); } } // Check to see if the pipeline has been closed. if (PExecutor.PLine.Output.EndOfPipeline) { // Bring back the exit code. ExitCode = RHost.ExitCode; } break; case 1: Collection<object> Errordata = PExecutor.PLine.Error.NonBlockingRead(); if (Errordata.Count > 0) { Error = true; for (int count = 0; count <= (Errordata.Count - 1); count++) { PSErrorCollection.Add(Errordata[count]); } } break; } } PExecutor.Stop(); // Create the Execution Return block ExecutionResults ER = new ExecutionResults(Block.RuleGuid,Block.SubRuleGuid, Block.MessageIdentfier); ER.ExitCode = ExitCode; // Add in the data results. lock (ReadSync) { if (PSCollection.Count > 0) { ER.DataAdd(PSCollection); } } // Add in the error data if any. if (Error) { if (PSErrorCollection.Count > 0) { ER.ErrorAdd(PSErrorCollection); } else { ER.InError = true; } } // We have finished, so enque the block back. EnQueueOutput(ER); } and this is the PipelineExecutor class which setups the pipeline for execution. public class PipelineExecutor { private Pipeline pipeline; private WaitHandle[] Handles; public Pipeline PLine { get { return pipeline; } } public WaitHandle[] Hand { get { return Handles; } } public PipelineExecutor(Runspace runSpace, string command) { pipeline = runSpace.CreatePipeline(command); Handles = new WaitHandle[2]; Handles[0] = pipeline.Output.WaitHandle; Handles[1] = pipeline.Error.WaitHandle; } public void Start() { if (pipeline.PipelineStateInfo.State == PipelineState.NotStarted) { pipeline.Input.Close(); pipeline.InvokeAsync(); } } public void Stop() { pipeline.StopAsync(); } } An this is the DataAdd method, where the exception arises. public void DataAdd(Collection<PSObject> Data) { foreach (PSObject Ps in Data) { Data.Add(Ps); } } I put a for loop around the Data.Add, and the Collection filled up with 600k+ so feels like the gps command is still running, but why. Any ideas. Thanks in advance.

    Read the article

  • What does this code do? Recursive Iterator in php?

    - by Ali
    I'm working on a zend framework based email project and I'm following some code samples online.. I can't understand this line of code which apparently loops through different 'parts' of an email message. I have no idea how it works btw and suspect that theres some error taking place which my parser isn't showing right. foreach (new RecursiveIteratorIterator($mail->getMessage($i)) as $ii=>$part) what does the above foreach loop mean?

    Read the article

  • I need to speed this code at least 2 times!

    - by Dominating
    include include include include using namespace std; inline void PrintMapName(multimap pN, string s) { pair::iterator, multimap::iterator ii; multimap::iterator it; ii = pN.equal_range(s); multimap tmp; for(it = ii.first; it != ii.second; ++it) { tmp.insert(pair(it-second,1)); } multimap::iterator i; bool flag = false; for(i = tmp.begin(); i != tmp.end(); i++) { if(flag) { cout<<" "; } cout<first; if(flag) { cout<<" "; } flag = true; } cout< int main() { multimap phoneNums; multimap numPhones; int N; cinN; int tests; string tmp, tmp1,tmp2; while(N 0) { cintests; while(tests 0) { cintmp; if(tmp == "add") { cintmp1tmp2; phoneNums.insert(pair(tmp1,tmp2)); numPhones.insert(pair(tmp2,tmp1)); } else { if(tmp == "delnum") { cintmp1; multimap::iterator it; multimap::iterator tmpr; for(it = phoneNums.begin(); it != phoneNums.end();it++) { tmpr = it; if(it-second == tmp1) { phoneNums.erase(it,tmpr); } } numPhones.erase(tmp1); } else { if(tmp == "delname") { cintmp1; phoneNums.erase(tmp1); multimap::iterator it; multimap::iterator tmpr; for(it = numPhones.begin(); it != numPhones.end();it++) { tmpr = it; if(it-second == tmp1) { numPhones.erase(it,tmpr); } } } else { if(tmp =="queryname") { cintmp1; PrintMapName(phoneNums, tmp1); } else//querynum { cintmp1; PrintMapName(numPhones, tmp1); } } } } tests--; } N--; } return 0; }

    Read the article

  • In Python, can I single line a for loop over iterator with an IF filter?

    - by Tal Weiss
    Silly question: I have a simple for loop followed by a simple if statement: for airport in airports: if airport.is_important: and I was wondering if I can write this as a single line somehow. So, yes, I can do this: for airport in (airport for airport in airports if airport.is_important): but it reads so silly and redundant ("for airport in airport for airport in airports..."). Is there a better way?

    Read the article

  • Is there a way to efficiently yield every file in a directory containing millions of files?

    - by Josh Smeaton
    I'm aware of os.listdir, but as far as I can gather, that gets all the filenames in a directory into memory, and then returns the list. What I want, is a way to yield a filename, work on it, and then yield the next one, without reading them all into memory. Is there any way to do this? I worry about the case where filenames change, new files are added, and files are deleted using such a method. Some iterators prevent you from modifying the collection during iteration, essentially by taking a snapshot of the state of the collection at the beginning, and comparing that state on each move operation. If there is an iterator capable of yielding filenames from a path, does it raise an error if there are filesystem changes (add, remove, rename files within the iterated directory) which modify the collection? There could potentially be a few cases that could cause the iterator to fail, and it all depends on how the iterator maintains state. Using S.Lotts example: filea.txt fileb.txt filec.txt Iterator yields filea.txt. During processing, filea.txt is renamed to filey.txt and fileb.txt is renamed to filez.txt. When the iterator attempts to get the next file, if it were to use the filename filea.txt to find it's current position in order to find the next file and filea.txt is not there, what would happen? It may not be able to recover it's position in the collection. Similarly, if the iterator were to fetch fileb.txt when yielding filea.txt, it could look up the position of fileb.txt, fail, and produce an error. If the iterator instead was able to somehow maintain an index dir.get_file(0), then maintaining positional state would not be affected, but some files could be missed, as their indexes could be moved to an index 'behind' the iterator. This is all theoretical of course, since there appears to be no built-in (python) way of iterating over the files in a directory. There are some great answers below, however, that solve the problem by using queues and notifications. Edit: The OS of concern is Redhat. My use case is this: Process A is continuously writing files to a storage location. Process B (the one I'm writing), will be iterating over these files, doing some processing based on the filename, and moving the files to another location. Edit: Definition of valid: Adjective 1. Well grounded or justifiable, pertinent. (Sorry S.Lott, I couldn't resist). I've edited the paragraph in question above.

    Read the article

  • terminate called after throwing an instance of 'std::length_error'

    - by mark
    hello all, this is my first post here. As i am newbie, the problem might be stupid. I was writing a piece of code while the following error message shown, terminate called after throwing an instance of 'std::length_error' what(): basic_string::_S_create /home/gcj/finals /home/gcj/quals where Aborted the following is the offending code especially Line 39 to Line 52. It is weired for me as this block of code is almost same as the Line64 to Line79. int main(){ std::vector<std::string> dirs, need; std::string tmp_str; std::ifstream fp_in("small.in"); std::ofstream fp_out("output"); std::string::iterator iter_substr_begin, iter_substr_end; std::string slash("/"); int T, N, M; fp_in>>T; for (int t = 0; t < T; t++){ std::cout<<" time "<< t << std::endl; fp_in >> N >> M; for (int n =0; n<N; n++){ fp_in>>tmp_str; dirs.push_back(tmp_str); tmp_str.clear(); } for (int m=0; m<M; m++){ fp_in>>tmp_str; need.push_back(tmp_str); tmp_str.clear(); } for (std::vector<std::string>::iterator iter = dirs.begin(); iter!=dirs.end(); iter++){ for (std::string::iterator iter_str = (*iter).begin()+1; iter_str<(*iter).end(); ++iter_str){ if ((*iter_str)=='/') { std::string tmp_str2((*iter).begin(), iter_str); if (find(dirs.begin(), dirs.end(), tmp_str2)==dirs.end()) { dirs.push_back(tmp_str2); } } } } for (std::vector<std::string>::iterator iter_tmp = dirs.begin(); iter_tmp!= dirs.end(); ++iter_tmp) std::cout<<*iter_tmp<<" "; dirs.clear(); std::cout<<std::endl; std::cout<<" need "<<std::endl; //processing the next for (std::vector<std::string>::iterator iter_tmp = need.begin(); iter_tmp!=need.end(); ++iter_tmp) std::cout<<*iter_tmp<<" "; std::cout<<" where "; for (std::vector<std::string>::iterator iter = need.begin(); iter!=need.end(); iter++){ for (std::string::iterator iter_str = (*iter).begin()+1; iter_str<(*iter).end(); ++iter_str){ if ((*iter_str)=='/') { std::string tmp_str2((*iter).begin(), iter_str); if (find(need.begin(), need.end(), tmp_str2)==need.end()) { need.push_back(tmp_str2); } } } } for (std::vector<std::string>::iterator iter_tmp = need.begin(); iter_tmp!= need.end(); ++iter_tmp) std::cout<<*iter_tmp<<" "; need.clear(); std::cout<<std::endl; //finish processing the next } for (std::vector<std::string>::iterator iter= dirs.begin(); iter!=dirs.end(); iter++) std::cout<<*iter<<" "; std::cout<<std::endl; for (std::vector<std::string>::iterator iter= need.begin(); iter!=need.end(); iter++) std::cout<<*iter<<" "; std::cout<<std::endl; fp_out.close(); } best regards, Mark

    Read the article

  • Parsing "true" and "false" using Boost.Spirit.Lex and Boost.Spirit.Qi

    - by Andrew Ross
    As the first stage of a larger grammar using Boost.Spirit I'm trying to parse "true" and "false" to produce the corresponding bool values, true and false. I'm using Spirit.Lex to tokenize the input and have a working implementation for integer and floating point literals (including those expressed in a relaxed scientific notation), exposing int and float attributes. Token definitions #include <boost/spirit/include/lex_lexertl.hpp> namespace lex = boost::spirit::lex; typedef boost::mpl::vector<int, float, bool> token_value_type; template <typename Lexer> struct basic_literal_tokens : lex::lexer<Lexer> { basic_literal_tokens() { this->self.add_pattern("INT", "[-+]?[0-9]+"); int_literal = "{INT}"; // To be lexed as a float a numeric literal must have a decimal point // or include an exponent, otherwise it will be considered an integer. float_literal = "{INT}(((\\.[0-9]+)([eE]{INT})?)|([eE]{INT}))"; literal_true = "true"; literal_false = "false"; this->self = literal_true | literal_false | float_literal | int_literal; } lex::token_def<int> int_literal; lex::token_def<float> float_literal; lex::token_def<bool> literal_true, literal_false; }; Testing parsing of float literals My real implementation uses Boost.Test, but this is a self-contained example. #include <string> #include <iostream> #include <cmath> #include <cstdlib> #include <limits> bool parse_and_check_float(std::string const & input, float expected) { typedef std::string::const_iterator base_iterator_type; typedef lex::lexertl::token<base_iterator_type, token_value_type > token_type; typedef lex::lexertl::lexer<token_type> lexer_type; basic_literal_tokens<lexer_type> basic_literal_lexer; base_iterator_type input_iter(input.begin()); float actual; bool result = lex::tokenize_and_parse(input_iter, input.end(), basic_literal_lexer, basic_literal_lexer.float_literal, actual); return result && std::abs(expected - actual) < std::numeric_limits<float>::epsilon(); } int main(int argc, char *argv[]) { if (parse_and_check_float("+31.4e-1", 3.14)) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } } Parsing "true" and "false" My problem is when trying to parse "true" and "false". This is the test code I'm using (after removing the Boost.Test parts): bool parse_and_check_bool(std::string const & input, bool expected) { typedef std::string::const_iterator base_iterator_type; typedef lex::lexertl::token<base_iterator_type, token_value_type > token_type; typedef lex::lexertl::lexer<token_type> lexer_type; basic_literal_tokens<lexer_type> basic_literal_lexer; base_iterator_type input_iter(input.begin()); bool actual; lex::token_def<bool> parser = expected ? basic_literal_lexer.literal_true : basic_literal_lexer.literal_false; bool result = lex::tokenize_and_parse(input_iter, input.end(), basic_literal_lexer, parser, actual); return result && actual == expected; } but compilation fails with: boost/spirit/home/qi/detail/assign_to.hpp: In function ‘void boost::spirit::traits::assign_to(const Iterator&, const Iterator&, Attribute&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Attribute = bool]’: boost/spirit/home/lex/lexer/lexertl/token.hpp:434: instantiated from ‘static void boost::spirit::traits::assign_to_attribute_from_value<Attribute, boost::spirit::lex::lexertl::token<Iterator, AttributeTypes, HasState>, void>::call(const boost::spirit::lex::lexertl::token<Iterator, AttributeTypes, HasState>&, Attribute&) [with Attribute = bool, Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, AttributeTypes = boost::mpl::vector<int, float, bool, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, HasState = mpl_::bool_<true>]’ ... backtrace of instantiation points .... boost/spirit/home/qi/detail/assign_to.hpp:79: error: no matching function for call to ‘boost::spirit::traits::assign_to_attribute_from_iterators<bool, __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, void>::call(const __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, const __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, bool&)’ boost/spirit/home/qi/detail/construct.hpp:64: note: candidates are: static void boost::spirit::traits::assign_to_attribute_from_iterators<bool, Iterator, void>::call(const Iterator&, const Iterator&, char&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >] My interpretation of this is that Spirit.Qi doesn't know how to convert a string to a bool - surely that's not the case? Has anyone else done this before? If so, how?

    Read the article

  • How to sort Map in Java

    - by kalpesh
    hi i want to sort map according to its key value plz see code below public static void main(String[] args) { SortedMap map = new TreeMap(); // Add some elements: map.put("2", "Two"); map.put("1", "One"); map.put("5", "Five"); map.put("4", "Four"); map.put("3", "Three"); map.put("10", "Ten"); map.put("12", "Twelve"); map.put("7", "Seven"); map.put("9", "Nine"); Iterator iterator = map.keySet().iterator(); while (iterator.hasNext()) { Object key = iterator.next(); System.out.println("key : " + key + " value :" + map.get(key)); } } Result Should come below key : 1 value :One key : 2 value :Two key : 3 value :Three key : 4 value :Four key : 5 value :Five key : 7 value :Seven key : 9 value :Nine key : 10 value :Ten key : 12 value :Twelve

    Read the article

  • Implementig Java Iterable<E> interface

    - by Metz
    Hi, i wrote this code: public class C1 implements Iterable<NC1> { private LinkedList<NC1> list; public static class NC1 { ... } ... x public Iterator<NC1> iterator() { return list.iterator(); } } but eclipse whines (at the x-ed line): - The return type is incompatible with Iterable<NC1>.iterator() - implements java.lang.Iterable<NC1>.iterator i don't understand where the mistake is. thanks in advance.

    Read the article

  • One liner for getting a sublist from a Set

    - by yegor256
    Is there a one-liner (maybe from Guava or Apache Collections) that gets a sublist from a set. Internally it should do something like this: public <T> List<T> sublist(Set<T> set, int count) { Iterator<T> iterator = set.iterator(); List<T> sublist = new LinkedList<T>(); int pos = 0; while (iterator.hasNext() && pos++ < count) { sublist.add(iterator.next()); } return sublist; } Obviously, if there are not enough elements it has to return as many as possible.

    Read the article

  • How can I implement a database TableView like thing in C++?

    - by Industrial-antidepressant
    How can I implement a TableView like thing in C++? I want to emulating a tiny relation database like thing in C++. I have data tables, and I want to transform it somehow, so I need a TableView like class. I want filtering, sorting, freely add and remove items and transforming (ex. view as UPPERCASE and so on). The whole thing is inside a GUI application, so datatables and views are attached to a GUI (or HTML or something). So how can I identify an item in the view? How can I signal it when the table is changed? Is there some design pattern for this? Here is a simple table, and a simple data item: #include <string> #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/random_access_index.hpp> using boost::multi_index_container; using namespace boost::multi_index; struct Data { Data() {} int id; std::string name; }; struct row{}; struct id{}; struct name{}; typedef boost::multi_index_container< Data, indexed_by< random_access<tag<row> >, ordered_unique<tag<id>, member<Data, int, &Data::id> >, ordered_unique<tag<name>, member<Data, std::string, &Data::name> > > > TDataTable; class DataTable { public: typedef Data item_type; typedef TDataTable::value_type value_type; typedef TDataTable::const_reference const_reference; typedef TDataTable::index<row>::type TRowIndex; typedef TDataTable::index<id>::type TIdIndex; typedef TDataTable::index<name>::type TNameIndex; typedef TRowIndex::iterator iterator; DataTable() : row_index(rule_table.get<row>()), id_index(rule_table.get<id>()), name_index(rule_table.get<name>()), row_index_writeable(rule_table.get<row>()) { } TDataTable::const_reference operator[](TDataTable::size_type n) const { return rule_table[n]; } std::pair<iterator,bool> push_back(const value_type& x) { return row_index_writeable.push_back(x); } iterator erase(iterator position) { return row_index_writeable.erase(position); } bool replace(iterator position,const value_type& x) { return row_index_writeable.replace(position, x); } template<typename InputIterator> void rearrange(InputIterator first) { return row_index_writeable.rearrange(first); } void print_table() const; unsigned size() const { return row_index.size(); } TDataTable rule_table; const TRowIndex& row_index; const TIdIndex& id_index; const TNameIndex& name_index; private: TRowIndex& row_index_writeable; }; class DataTableView { DataTableView(const DataTable& source_table) {} // How can I implement this? // I want filtering, sorting, signaling upper GUI layer, and sorting, and ... }; int main() { Data data1; data1.id = 1; data1.name = "name1"; Data data2; data2.id = 2; data2.name = "name2"; DataTable table; table.push_back(data1); DataTable::iterator it1 = table.row_index.iterator_to(table[0]); table.erase(it1); table.push_back(data1); Data new_data(table[0]); new_data.name = "new_name"; table.replace(table.row_index.iterator_to(table[0]), new_data); for (unsigned i = 0; i < table.size(); ++i) std::cout << table[i].name << std::endl; #if 0 // using scenarios: DataTableView table_view(table); table_view.fill_from_source(); // synchronization with source table_view.remove(data_item1); // remove item from view table_view.add(data_item2); // add item from source table table_view.filter(filterfunc); // filtering table_view.sort(sortfunc); // sorting // modifying from source_able, hot to signal the table_view? // FYI: Table view is atteched to a GUI item table.erase(data); table.replace(data); #endif return 0; }

    Read the article

  • two HashMap iteration

    - by user431276
    I have two HashMaps and I can iterate both hashmaps with following code Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); String firstVal = pairs.getValue(); } Iterator it2 = mp2.entrySet().iterator(); while (it2.hasNext()) { Map.Entry pairs2 = (Map.Entry)it.next(); String SecondVal = pairs2.getValue(); } myFunction(firstVal, SecondVal) Is there anyway to iterate two hashmaps at the same time without using two loops? Currently, I have a method that accepts two parameters and each parameter value is stored in first and second hashmap. I have to iterate first hash then second to get values. I think there must be a good way to do it but I don't know :( P.S: there could be some errors in above code as this is just an example to explain my problem. Each iterator is a method in original program and accept one parameter. I couldn't copy past real time functions as they are HUGE !

    Read the article

  • Boost::asio bug in MSVC10 - Failing BOOST_WORKAROUND in ~buffer_debug_check() in buffer.hpp

    - by shaz
    A straight compilation of example http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/tutorial/tutdaytime3/src.html results in a runtime null pointer exception. Stack trace points to the buffer_debug_check destructor which contains this comment: // MSVC's string iterator checking may crash in a std::string::iterator // object's destructor when the iterator points to an already-destroyed // std::string object, unless the iterator is cleared first. The test #if BOOST_WORKAROUND(BOOST_MSVC, = 1400) succeeds in MSVC10 and (but) results in a null pointer exception in c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility line 123 _Iterator_base12& operator=(const _Iterator_base12& _Right) { // assign an iterator if (_Myproxy != _Right._Myproxy) _Adopt(_Right._Myproxy->_Mycont); return (*this); } _Right._Myproxy is NULL

    Read the article

  • How do UEFI and virtual machines relate to each other?

    - by Iterator
    I am trying to get my head around UEFI (Unified Extensible Firmware Interface) and it's not entirely clear to me how this affects virtual machines. Thus, there are three parts to this question: Is UEFI an advance in hardware support for virtualization? All other things being equal, would a machine with UEFI be more likely to run a virtual machine more efficiently than one without, or does UEFI cause any performance hits that negate any speed improvements from a virtual machine? Would the difference in execution be visible to code running in a virtual machine? (In theory, it shouldn't, but in practice?)

    Read the article

  • GPS on emulator doesn't get the geo fix - Android

    - by MaurizioPz
    Hi I'm developing an application for the android OS, I'm just starting, but I can't get the GPS on the emulator to work. I've read on the internet that you need to send a geo fix to the emulator in order to enable the gps locationProvider. I'm both using the DDMS and telnet to try to send it, but logcat never tells me the it recived a new fix, and my apolication still sees the gps as disabled here's my code package eu.mauriziopz.gps; import java.util.Iterator; import java.util.List; import android.app.Activity; import android.content.Context; import android.location.LocationManager; import android.os.Bundle; import android.util.Log; public class ggps extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); LocationManager l =(LocationManager) getSystemService(Context.LOCATION_SERVICE); List<String> li = l.getAllProviders(); for (Iterator<String> iterator = li.iterator(); iterator.hasNext();) { String string = iterator.next(); Log.d("gps", string); } if (l.getLastKnownLocation("gps")==null) Log.d("gps", "null"); } } I've read that the DDMS may not work properly on a non english OS, but telnet should work! update: the gps is enabled in the settings

    Read the article

  • How do I draw a scene with 2 nested frames

    - by Guido Granobles
    I have been trying for long time to figure out this: I have loaded a model from a directx file (I am using opengl and Java) the model have a hierarchical system of nested reference frames (there are not bones). There are just 2 frames, one of them is called x3ds_Torso and it has a child frame called x3ds_Arm_01. Each one of them has a mesh. The thing is that I can't draw the arm connected to the body. Sometimes the body is in the center of the screen and the arm is at the top. Sometimes they are both in the center. I know that I have to multiply the matrix transformation of every frame by its parent frame starting from the top to the bottom and after that I have to multiply every vertex of every mesh by its final transformation matrix. So I have this: public void calculeFinalMatrixPosition(Bone boneParent, Bone bone) { System.out.println("-->" + bone.name); if (boneParent != null) { bone.matrixCombined = bone.matrixTransform.multiply(boneParent.matrixCombined); } else { bone.matrixCombined = bone.matrixTransform; } bone.matrixFinal = bone.matrixCombined; for (Bone childBone : bone.boneChilds) { calculeFinalMatrixPosition(bone, childBone); } } Then I have to multiply every vertex of the mesh: public void transformVertex(Bone bone) { for (Iterator<Mesh> iterator = meshes.iterator(); iterator.hasNext();) { Mesh mesh = iterator.next(); if (mesh.boneName.equals(bone.name)) { float[] vertex = new float[4]; double[] newVertex = new double[3]; if (mesh.skinnedVertexBuffer == null) { mesh.skinnedVertexBuffer = new FloatDataBuffer( mesh.numVertices, 3); } mesh.vertexBuffer.buffer.rewind(); while (mesh.vertexBuffer.buffer.hasRemaining()) { vertex[0] = mesh.vertexBuffer.buffer.get(); vertex[1] = mesh.vertexBuffer.buffer.get(); vertex[2] = mesh.vertexBuffer.buffer.get(); vertex[3] = 1; newVertex = bone.matrixFinal.transpose().multiply(vertex); mesh.skinnedVertexBuffer.buffer.put(((float) newVertex[0])); mesh.skinnedVertexBuffer.buffer.put(((float) newVertex[1])); mesh.skinnedVertexBuffer.buffer.put(((float) newVertex[2])); } mesh.vertexBuffer = new FloatDataBuffer( mesh.numVertices, 3); mesh.skinnedVertexBuffer.buffer.rewind(); mesh.vertexBuffer.buffer.put(mesh.skinnedVertexBuffer.buffer); } } for (Bone childBone : bone.boneChilds) { transformVertex(childBone); } } I know this is not the more efficient code but by now I just want to understand exactly how a hierarchical model is organized and how I can draw it on the screen. Thanks in advance for your help.

    Read the article

  • C++ Using a class template argument as a template argument for another type

    - by toefel
    Hey Everyone, I'm having this problem while writing my own HashTable. It all works, but when I try to templatize the thing, it gave me errors. I recreated the problem as follows: THIS CODE WORKS: typedef double Item; class A { public: A() { v.push_back(pair<string, Item>("hey", 5.0)); } void iterate() { for(Iterator iter = v.begin(); iter != v.end(); ++iter) cout << iter->first << ", " << iter->second << endl; } private: vector<pair<string, double> > v; typedef vector< pair<string, double> >::iterator Iterator; }; THIS CODE DOES NOT: template<typename ValueType> class B { public: B(){} void iterate() { for(Iterator iter = v.begin(); iter != v.end(); ++iter) cout << iter->first << ", " << iter->second << endl; } private: vector<pair<string, ValueType> > v; typedef vector< pair<string, ValueType> >::iterator Iterator; }; the error messages: g++ -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ..\main.cpp ..\main.cpp:50: error: type std::vector<std::pair<std::string, ValueType>, std::allocator<std::pair<std::string, ValueType> > >' is not derived from typeB' ..\main.cpp:50: error: ISO C++ forbids declaration of `iterator' with no type ..\main.cpp:50: error: expected `;' before "Iterator" ..\main.cpp: In member function `void B::iterate()': ..\main.cpp:44: error: `Iterator' was not declared in this scope ..\main.cpp:44: error: expected `;' before "iter" ..\main.cpp:44: error: `iter' was not declared in this scope Does anybody know why this is happening? Thanks!

    Read the article

  • Towards Ultra-Reusability for ADF - Adaptive Bindings

    - by Duncan Mills
    The task flow mechanism embodies one of the key value propositions of the ADF Framework, it's primary contribution being the componentization of your applications and implicitly the introduction of a re-use culture, particularly in large applications. However, what if we could do more? How could we make task flows even more re-usable than they are today? Well one great technique is to take advantage of a feature that is already present in the framework, a feature which I will call, for want of a better name, "adaptive bindings". What's an adaptive binding? well consider a simple use case.  I have several screens within my application which display tabular data which are all essentially identical, the only difference is that they happen to be based on different data collections (View Objects, Bean collections, whatever) , and have a different set of columns. Apart from that, however, they happen to be identical; same toolbar, same key functions and so on. So wouldn't it be nice if I could have a single parametrized task flow to represent that type of UI and reuse it? Hold on you say, great idea, however, to do that we'd run into problems. Each different collection that I want to display needs different entries in the pageDef file and: I want to continue to use the ADF Bindings mechanism rather than dropping back to passing the whole collection into the taskflow   If I do use bindings, there is no way I want to have to declare iterators and tree bindings for every possible collection that I might want the flow to handle  Ah, joy! I reply, no need to panic, you can just use adaptive bindings. Defining an Adaptive Binding  It's easiest to explain with a simple before and after use case.  Here's a basic pageDef definition for our familiar Departments table.  <executables> <iterator Binds="DepartmentsView1" DataControl="HRAppModuleDataControl" RangeSize="25"             id="DepartmentsView1Iterator"/> </executables> <bindings> <tree IterBinding="DepartmentsView1Iterator" id="DepartmentsView1">   <nodeDefinition DefName="oracle.demo.model.vo.DepartmentsView" Name="DepartmentsView10">     <AttrNames>       <Item Value="DepartmentId"/>         <Item Value="DepartmentName"/>         <Item Value="ManagerId"/>         <Item Value="LocationId"/>       </AttrNames>     </nodeDefinition> </tree> </bindings>  Here's the adaptive version: <executables> <iterator Binds="${pageFlowScope.voName}" DataControl="HRAppModuleDataControl" RangeSize="25"             id="TableSourceIterator"/> </executables> <bindings> <tree IterBinding="TableSourceIterator" id="GenericView"> <nodeDefinition Name="GenericViewNode"/> </tree> </bindings>  You'll notice three changes here.   Most importantly, you'll see that the hard-coded View Object name  that formally populated the iterator Binds attribute is gone and has been replaced by an expression (${pageFlowScope.voName}). This of course, is key, you can see that we can pass a parameter to the task flow, telling it exactly what VO to instantiate to populate this table! I've changed the IDs of the iterator and the tree binding, simply to reflect that they are now re-usable The tree binding itself has simplified and the node definition is now empty.  Now what this effectively means is that the #{node} map exposed through the tree binding will expose every attribute of the underlying iterator's collection - neat! (kudos to Eugene Fedorenko at this point who reminded me that this was even possible in his excellent "deep dive" session at OpenWorld  this year) Using the adaptive binding in the UI Now we have a parametrized  binding we have to make changes in the UI as well, first of all to reflect the new ID that we've assigned to the binding (of course) but also to change the column list from being a fixed known list to being a generic metadata driven set: <af:table value="#{bindings.GenericView.collectionModel}" rows="#{bindings.GenericView.rangeSize}"         fetchSize="#{bindings.GenericView.rangeSize}"           emptyText="#{bindings.GenericView.viewable ? 'No data to display.' : 'Access Denied.'}"           var="row" rowBandingInterval="0"           selectedRowKeys="#{bindings.GenericView.collectionModel.selectedRow}"           selectionListener="#{bindings.GenericView.collectionModel.makeCurrent}"           rowSelection="single" id="t1"> <af:forEach items="#{bindings.GenericView.attributeDefs}" var="def">   <af:column headerText="#{bindings.GenericView.labels[def.name]}" sortable="true"            sortProperty="#{def.name}" id="c1">     <af:outputText value="#{row[def.name]}" id="ot1"/>     </af:column>   </af:forEach> </af:table> Of course you are not constrained to a simple read only table here.  It's a normal tree binding and iterator that you are using behind the scenes so you can do all the usual things, but you can see the value of using ADFBC as the back end model as you have the rich pantheon of UI hints to use to derive things like labels (and validators and converters...)  One Final Twist  To finish on a high note I wanted to point out that you can take this even further and achieve the ultra-reusability I promised. Here's the new version of the pageDef iterator, see if you can notice the subtle change? <iterator Binds="{pageFlowScope.voName}"  DataControl="${pageFlowScope.dataControlName}" RangeSize="25"           id="TableSourceIterator"/>  Yes, as well as parametrizing the collection (VO) name, we can also parametrize the name of the data control. So your task flow can graduate from being re-usable within an application to being truly generic. So if you have some really common patterns within your app you can wrap them up and reuse then across multiple developments without having to dictate data control names, or connection names. This also demonstrates the importance of interacting with data only via the binding layer APIs. If you keep any code in the task flow generic in that way you can deal with data from multiple types of data controls, not just one flavour. Enjoy!

    Read the article

  • Efficiency of iterators and alternatives? [migrated]

    - by user48037
    I have the following code for my game tiles: std::vector<GameObject_Tile*>::iterator it; for(int y = 0; y < GAME_TILES_Y; y++) { for(int x = 0; x < GAME_TILES_X; x++) { for (it = gameTiles[x][y].tiles.begin() ; it != gameTiles[x][y].tiles.end(); ++it) {}}} tiles is: struct Game_Tile { // More specific object types will be added here eventually vector<GameObject_Tile*> tiles; }; My problem is that if I change the vector to just be a single GameObject_Tile* instead and remove the iterator line in the loop I go from about 200fps to 450fps. Some context: The vector/pointer only contains one object in both scenarios. I will eventually need to store multiple, but for testing I just set it to a single pointer. The loop goes through 2,300 objects each frame and draws them. I would like to point out that if I remove the Draw (not seen int he example) method, I gain about 30 frames in both scenarios, the issue is the iteration. So I am wondering why having this as a vector being looped through by an iterator (to get at a single object) is costing me over 200 frames when compared to it being a single pointer? The 200+ frames faster code is: std::vector<GameObject_Tile*>::iterator it; for(int y = 0; y < GAME_TILES_Y; y++) { for(int x = 0; x < GAME_TILES_X; x++) { //gameTiles[x][y].tiles is used as a pointer here instead of using *it }} tiles is: struct Game_Tile { // More specific object types will be added here eventually GameObject_Tile* tiles; };

    Read the article

  • multimap erase doesnt work

    - by nikiforzx6r
    following code doensnt work with input: 2 7 add Elly 0888424242 add Elly 0883666666 queryname Elly querynum 0883266642 querynum 0888424242 delnum 0883666666 queryname Elly 3 add Kriss 42 add Elly 42 querynum 42 Why my erase doesnt work? #include<stdio.h> #include<iostream> #include<map> #include <string> using namespace std; void PrintMapName(multimap<string, string> pN, string s) { pair<multimap<string,string>::iterator, multimap<string,string>::iterator> ii; multimap<string, string>::iterator it; ii = pN.equal_range(s); multimap<string, int> tmp; for(it = ii.first; it != ii.second; ++it) { tmp.insert(pair<string,int>(it->second,1)); } multimap<string, int>::iterator i; bool flag = false; for(i = tmp.begin(); i != tmp.end(); i++) { if(flag) { cout<<" "; } cout<<i->first; if(flag) { cout<<" "; } flag = true; } cout<<endl; } void PrintMapNumber(multimap<string, string> pN, string s) { multimap<string, string>::iterator it; multimap<string, int> tmp; for(it = pN.begin(); it != pN.end(); it++ ) { if(it->second == s) { tmp.insert(pair<string,int>(it->first,1)); } } multimap<string, int>::iterator i; bool flag = false; for(i = tmp.begin(); i != tmp.end(); i++) { if(flag) { cout<<" "; } cout<<i->first; if(flag) { cout<<" "; } flag = true; } cout<<endl; } void PrintFull(multimap<string, string> pN) { multimap<string, string>::iterator it; for(it = pN.begin(); it != pN.end(); it++ ) { cout<<"Key = "<<it->first<<" Value = "<<it->second<<endl; } } int main() { multimap<string, string> phoneNums; int N; cin>>N; int tests; string tmp, tmp1,tmp2; while(N > 0) { cin>>tests; while(tests > 0) { cin>>tmp; if(tmp == "add") { cin>>tmp1>>tmp2; phoneNums.insert(pair<string,string>(tmp1,tmp2)); } else { if(tmp == "delnum") { /////////////////////////////////////////HEREEEEEEE multimap<string, string>::iterator it; multimap<string, string>::iterator tmpr; for(it = phoneNums.begin(); it != phoneNums.end();) { tmpr = it; if(it->second == tmp1) { ++tmpr; if(tmpr == phoneNums.end()) { phoneNums.erase(it,tmpr); break; } else { phoneNums.erase(it,tmpr); } } } } else { if(tmp == "delname") { cin>>tmp1; phoneNums.erase(tmp1); } else { if(tmp =="queryname") { cin>>tmp1; PrintMapName(phoneNums, tmp1); } else//querynum { cin>>tmp1; PrintMapNumber(phoneNums, tmp1); } } } } tests--; } N--; } return 0; }

    Read the article

  • Iterating selected rows in an ADF Faces table

    - by Frank Nimphius
    In OTN Harvest May 2012; http://www.oracle.com/technetwork/developer-tools/adf/learnmore/may2012-otn-harvest-1652358.pdf I wrote about "Common mistake when iterating <af:table> rows". In this entry I showed code to access the row associated with a selected table row from the binding layer to avoid the problem of having to programmatically change the selected table row. As it turns out, my solution only worked fro selected table rows that are in the current iterator query range. So here's a solution that works for all ranges public String onButtonPress() { RowKeySet rks = table.getSelectedRowKeys(); Iterator it = rks.iterator(); while (it.hasNext()) { List selectedRowKeyPath = (List)it.next(); //table is the JSF component reference created using the table's binding //property Row row = ((JUCtrlHierNodeBinding)table.getRowData(selectedRowKeyPath)).getRow(); System.out.println("Print Test: " + row.getAttribute(1)); } return null; }

    Read the article

  • Checking collision of bullets and Asteroids

    - by Moaz ELdeen
    I'm trying to detect collision between two list of bullets and asteroids. The code works fine, but when the bullet intersects with an asteroid, and that bullet passes through another asteroid, the code gives an assertion, and it says about it can't increment the iterator. I'm sure there is a small bug in that code, but I can't find it. for (list<Bullet>::iterator itr_bullet = ship.m_Bullets.begin(); itr_bullet!=ship.m_Bullets.end();) { for (list<Asteroid>::iterator itr_astroid = asteroids.begin(); itr_astroid!=asteroids.end(); itr_astroid++) { if(checkCollision(itr_bullet->getCenter(),itr_astroid->getCenter(), itr_bullet->getRadius(), itr_astroid->getRadius())) { itr_astroid = asteroids.erase(itr_astroid); } } itr_bullet++; }

    Read the article

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