Search Results

Search found 2235 results on 90 pages for 'dictionary'.

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

  • Cannot access NSDictionary

    - by michael blaize
    I created a JSON using a PHP script. I am reading the JSON and can see that the data has been correctly read. However, when it comes to access the objects I get unrecognized selector sent to instance... Cannot seem to find why that is after too many hours !!!! Any help would be great ! My code looks like that: `NSDictionary *json = [[NSDictionary alloc] init]; json = [NSJSONSerialization JSONObjectWithData:receivedData options:kNilOptions error:&error]; NSLog(@"raw json = %@,%@",json,error); NSMutableArray *name = [[NSMutableArray alloc] init]; [name addObjectsFromArray: [json objectForKey:@"name"]];` The code crashes when reaching the last line above. The output like this: raw json = ( { category = vacancies; link = "http://blablabla.com"; name = "name 111111"; tagline = "tagline 111111"; }, { category = vacancies; link = "http://blobloblo.com"; name = "name 222222222"; tagline = "tagline 222222222"; } ),(null) 2012-06-23 21:46:57.539 Wind expert[4302:15203] -[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0xdcfb970 HELP !!!

    Read the article

  • How to make simple dicitonary J2ME

    - by batosai_fk
    Hi, I am beginner in JavaME. I'd like to make simple dicitionary. The source data is placed on "data.txt" file in "res" directory. The structure is like this: #apple=kind of fruit; #spinach=kind of vegetable; The flow is so simple. User enters word that he want to search in a text field, e.g "apple", system take the user input, read the "data.txt", search the matched word in it, take corresponding word, and display it to another textfield/textbox. I've managed to read whole "data.txt" using this code.. private String readDataText() { InputStream is = getClass().getResourceAsStream("data.txt"); try { StringBuffer sb = new StringBuffer(); int chr, i=0; while ((chr = is.read()) != -1) sb.append((char) chr); return sb.toString(); } catch (Exception e) { } return null; } but I still dont know how to split it, find the matched word with the user input and take corresponding word. Hope somebody willing to share his/her knowledge to help me.. Add to batosai_fk's Reputation

    Read the article

  • Efficient mapping of game entity positions in Java

    - by byte
    In Java (Swing), say I've got a 2D game where I have various types of entities on the screen, such as a player, bad guys, powerups, etc. When the player moves across the screen, in order to do efficient checking of what is in the immediate vicinity of the player, I would think I'd want indexed access to the things that are near the character based on their position. For example, if player 'P' steps onto element 'E' in the following example... | | | | | | | | | |P| | | | |E| | | | | | | | | ... would be to do something like: if(player.getPosition().x == entity.getPosition().x && entity.getPosition.y == thing.getPosition().y) { //do something } And thats fine, but that implies that the entities hold their positions, and therefor if I had MANY entities on the screen I would have to loop through all possible entities available and check each ones position against the player position. This seems really inefficient especially if you start getting tons of entities. So, I would suspect I'd want some sort of map like Map<Point, Entity> map = new HashMap<Point, Entity>(); And store my point information there, so that I could access these entities in constant time. The only problem with that approach is that, if I want to move an entity to a different point on the screen, I'd have to search through the values of the HashMap for the entity I want to move (inefficient since I dont know its Point position ahead of time), and then once I've found it remove it from the HashMap, and re-insert it with the new position information. Any suggestions or advice on what sort of data structure / storage format I ought to be using here in order to have efficient access to Entities based on their position, as well as Position's based on the Entity?

    Read the article

  • How can you tell which columns are unused in ALL_TAB_COLS?

    - by thecoop
    When you query the ALL_TAB_COLS view on Oracle 9i, it lists columns marked as UNUSED as well as the 'active' table columns. There doesn't seem to be a field that explicitly says whether a column is UNUSED, or any view I can join to that lists the unused columns in a table. How can I easily find out which are the unused columns, so I can filter them out of ALL_TAB_COLS?

    Read the article

  • Appropriate collection for variable-depth list?

    - by George R
    If I wanted to have a collection that described the (recursive) contents of a root directory, including directories and files, how would I store them? Or do I need to come up with an object that holds: -Current directory -Parent directory -Files in directory ..and slap them all in one big list and manually work out the relationship at runtime from each entries Parent directory.

    Read the article

  • printing out dictionnaires

    - by kyril
    I have a rather specific question: I want to print out characters at a specific place using the \033[ syntax. This is what the code below should do: (the dict cells has the same keys as coords but with either '*' or '-' as value.) coords = {'x'+str(x)+'y'+str(y) : (x,y) for x,y, in itertools.product(range(60), range(20))} for key, value in coords.items(): char = cells[key] x,y = value HORIZ=str(x) VERT=str(y) char = str(char) print('\033['+VERT+';'+HORIZ+'f'+char) However, I noticed that if I put this into a infinite while loop, it does not always prints the same characters at the same position. There are only slight changes, but it deletes some and puts them back in after some loops. I already tried it with lists, and there it seems to behave just fine, so I tend to think it has something todo with the dict, but I can not figure out what it could be. You can see the Problem in a console here: SharedConsole.I am happy for every tip on this matter. On a related topic: After the printing, some changes should be made at the values of the cells dict, but for reason unknown to me, the only the first two rules are executed and the rest is ignored. The rules should test how many neighbours (which is in population) are around the cell and apply the according rule. In my implemention of this I have some kind of weird tumor growth (which should not happen, as if there more than three around they should the cell should die) (see FreakingTumor): if cells_copy [coord] == '-': if population == 3: cells [coord] = '*' if cells_copy [coord] == '*': if population > 3: cells [coord] = '-' elif population <= 1: cells [coord] = '-' elif population == 2 or 3: cells [coord] = '*' I checked the population variable several times, so I am quite sure that is not the matter. I am sorry for the slow consoles. Thanks in advance! Kyril

    Read the article

  • C#: Get key and value types of non-generic IDictionary at runtime

    - by Yang Zou
    there. I am wondering how I can get the key and value types of a non-generic IDictionary at runtime. For generic IDictionary, we can use reflection to get the generic arguments, which has been answered here. But for non-generic IDictionary, for instance, HybridDictionary, how can I get the key and value types? Thanks. Edit: I may not describe my problem properly. For non-generic IDictionary, if I have HyBridDictionary, which is declared as HyBridDictionary dict = new HyBridDictionary(); dict.Add("foo" , 1); dict.Add("bar", 2); How can I find out the type of the key is string and type of the value is int? Did I make the question clear? Thanks.

    Read the article

  • Returning all "positions" of a list

    - by Daymor
    I Have a list with "a" and "b" and the "b"'s are somewhat of a path and "a"'s are walls. Im writing a program to make a graph of all the possible moves. I got the code running to check the first "b" for possible moves, but i have NO Idea how im going to find all "b"'s , even less check them all without repeating. Major issue im having is getting the tuple coordinates of the "b"'s out of the list. Any pointers/tips?

    Read the article

  • delete common dictionaries in list based on a value

    - by pythoonatic
    How would I delete all corresponding dictionaries in a list of dictionaries based on one of the dictionaries having a character in it. data = [ { 'x' : 'a', 'y' : '1' }, { 'x' : 'a', 'y' : '1/1' }, { 'x' : 'a', 'y' : '2' }, { 'x' : 'b', 'y' : '1' }, { 'x' : 'b', 'y' : '1' }, { 'x' : 'b', 'y' : '1' }, ] For example, how would I delete all of the x = a due to one of the y in the x=a having a / in it? Based on the example data above, here is where I would like to get to: cleaneddata = [ { 'x' : 'b', 'y' : '1' }, { 'x' : 'b', 'y' : '1' }, { 'x' : 'b', 'y' : '1' }, ]

    Read the article

  • How can I create a rules engine without using eval() or exec()?

    - by Angela
    I have a simple rules/conditions table in my database which is used to generate alerts for one of our systems. I want to create a rules engine or a domain specific language. A simple rule stored in this table would be..(omitting the relationships here) if temp > 40 send email Please note there would be many more such rules. A script runs once daily to evaluate these rules and perform the necessary actions. At the beginning, there was only one rule, so we had the script in place to only support that rule. However we now need to make it more scalable to support different conditions/rules. I have looked into rules engines , but I hope to achieve this in some simple pythonic way. At the moment, I have only come up with eval/exec and I know that is not the most recommended approach. So, what would be the best way to accomplish this?? ( The rules are stored as data in database so each object like "temperature", condition like "/=..etc" , value like "40,50..etc" and action like "email, sms, etc.." are stored in the database, i retrieve this to form the condition...if temp 50 send email, that was my idea to then use exec or eval on them to make it live code..but not sure if this is the right approach )

    Read the article

  • Efficient way to access a mapping of identifiers in Python

    - by sixbelo
    I am writing an app to do a file conversion and part of that is replacing old account numbers with a new account numbers. Right now I have a CSV file mapping the old and new account numbers with around 30K records. I read this in and store it as dict and when writing the new file grab the new account from the dict by key. My question is what is the best way to do this if the CSV file increases to 100K+ records? Would it be more efficient to convert the account mappings from a CSV to a sqlite database rather than storing them as a dict in memory?

    Read the article

  • Pair attribute naming in custom configSections

    - by fearofawhackplanet
    I'm trying to store a user list in a config file. I've been looking at DictionarySectionHandler and NameValueSectionHandler. I'm not too sure what the difference between these two is, but anyway, neither of them do exactly what I'd like. You can add a custom config section like so: <configSections> <section name="userAges" type="System.Configuration.DictionarySectionHandler"/> </configSections> <userAges> <add key="userName1" value="10" /> <add key="userName2" value="52" /> <userAges> Which is ok, but actually I'd prefer to be able to write: ... <userAges> <add user="userName1" age="10" /> <add user="userName2" age="52" /> <userAges> Which I feel would make the config file clearer to anyone who needed to add/remove users in future. Is there an easy way to do this?

    Read the article

  • How can I get running totals of integer values from a SortedDictionary?

    - by user578083
    SortedDictionary<int, string> typeDictionary = new SortedDictionary<int, string>(); SortedDictionary<int, int> lengthDictionary = new SortedDictionary<int, int>(); lengthDictionary has values in key value pair as follows: <1,20> <2,8> <3,10> <4,5> i want LINQ query which will return me new list like as follows <1,20> <2,20+8=28> // 20 from key 1 <3,28+10=38> // 28 from key 2 <4,38+5=43> // 38 from key 3 Result should like this: <1,20> <2,28> <3,38> <4,43>

    Read the article

  • How do I most efficienty check the unique elements in a list?

    - by alex
    let's say I have a list li = [{'q':'apple','code':'2B'}, {'q':'orange','code':'2A'}, {'q':'plum','code':'2A'}] What is the most efficient way to return the count of unique "codes" in this list? In this case, the unique codes is 2, because only 2B and 2A are unique. I could put everything in a list and compare, but is this really efficient?

    Read the article

  • Is there an easy way to "append()" two dictionaries together in Python?

    - by digitaldreamer
    If I have two dictionaries I'd like to combine in Python, i.e. a = {'1': 1, '2': 2} b = {'3': 3, '4': 4} If I run update on them it reorders the list: a.update(b) {'1': 1, '3': 3, '2': 2, '4': 4} when what I really want is attach "b" to the end of "a": {'1': 1, '2': 2, '3': 3, '4': 4} Is there an easy way to attach "b" to the end of "a" without having to manually combine them like so: for key in b: a[key]=b[key] Something like += or append() would be ideal, but of course neither works on dictionaries.

    Read the article

  • Convert list of dicts to string

    - by John
    I'm very new to Python, so forgive me if this is easier than it seems to me. I'm being presented with a list of dicts as follows: [{'directMember': 'true', 'memberType': 'User', 'memberId': '[email protected]'}, {'directMember': 'true', 'memberType': 'User', 'memberId': '[email protected]'}, {'directMember': 'true', 'memberType': 'User', 'memberId': '[email protected]'}] I would like to generate a simple string of memberIds, such as [email protected], [email protected], [email protected] but every method of converting a list to a string that I have tried fails because dicts are involved. Any advice?

    Read the article

  • Creating, using and managing XML component dictionaries quick tutorials

    - by drrwebber
    XML Component Dictionary capabilities are provided in conjunction with the CAM Editor toolset.  These dictionaries accelerate the development of consistent XML information exchanges using standard sets of dictionary components. The quick tutorials are aimed at showing the 'how to' of the basic capabilities to jump start use of XML dictionaries with the CAM Editor. The collection of dictionary tutorials videos run for a total of approximately 20 minutes.  Each video can be reviewed individually also. Learn how to use the dictionary functions to create dictionaries by harvesting data model components from existing XSD schema, SQL database table schema, or simple Excel / Open Office spreadsheets with tables of components listed.Also included are tips and functions relating to use of NIEM exchange development, IEPD and EIEM techniques.These videos should be viewed in conjunction with reviewing the overall concepts and techniques described in the companion video on the CAM Editor and Dictionaries overview.  The approach is aligned with OASIS and Core Components Technical Specification (CCTS) standards specifications for XML components and dictionaries.Dictionary collections can be stored locally on the file system, or local network, or collaboratively on the web or cloud deployment, or can be shared and managed securely using the Oracle Enterprise Repository (OER) tool. Also included are techniques relating to the use of the NIEM approach for developing XML exchange schema and IEPD packages.  This includes generating reuse scores, wantlist, and cross reference spreadsheets. Included in the latest release of the CAM Editor is the ability to use the analyse dictionary tool to determine duplicate components, conflicting component definitions, missing component descriptions and so on.  This ensures high quality dictionary component specifications.  Using the CAM Editor you can also create MindMap models and UML physical models of your dictionary components sets. For a complete guide to using the CAM Editor see the main YouTube video tutorials website and the CAM Editor website.

    Read the article

  • Is it worth caching a Dictionary for foreign key values in ASP.net?

    - by user169867
    I have a Dictionary<int, string> cached (for 20 minutes) that has ~120 ID/Name pairs for a reference table. I iterate over this collection when populating dropdown lists and I'm pretty sure this is faster than querying the DB for the full list each time. My question is more about if it makes sense to use this cached dictionary when displaying records that have a foreign key into this reference table. Say this cached reference table is a EmployeeType table. If I were to query and display a list of employee names and types should I query for EmployeeName and EmployeeTypeID and use my cached dictionary to grab the EmployeeTypeIDs name as each record is displayed or is it faster to just have the DB grab the EmployeeName and JOIN to get the EmployeeType string bypassing the cached Dictionary all together. I know both will work but I'm interested in what will perform the fastest. Thanks for any help.

    Read the article

  • Pickled my dictionary from ZODB but i got a less in size one?

    - by Someone Someoneelse
    I use ZODB and i want to copy my 'database_1.fs' file to another 'database_2.fs', so I opened the root dictionary of that 'database_1.fs' and I (pickle.dump) it in a text file. Then I (pickle.load) it in a dictionary-variable, in the end I update the root dictionary of the other 'database_2.fs' with the dictionary-variable. It works, but I wonder why the size of the 'database_1.fs' not equal to the size of the other 'database_2.fs'. They are still copies of each other. def openstorage(store): #opens the database data={} data['file']=filestorage data['db']=DB(data['file']) data['conn']=data['db'].open() data['root']=data['conn'].root() return data def getroot(dicty): return dicty['root'] def closestorage(dicty): #close the database after Saving transaction.commit() dicty['file'].close() dicty['db'].close() dicty['conn'].close() transaction.get().abort() then that's what i do:- import pickle loc1='G:\\database_1.fs' op1=openstorage(loc1) root1=getroot(op1) loc2='G:database_2.fs' op2=openstorage(loc2) root2=getroot(op2) >>> len(root1) 215 >>> len(root2) 0 pickle.dump( root1, open( "save.txt", "wb" )) item=pickle.load( open( "save.txt", "rb" ) ) #now item is a dictionary root2.update(item) closestorage(op1) closestorage(op2) #after I open both of the databases #I get the same keys in both databases #But `database_2.fs` is smaller that `database_2.fs` in size I mean. >>> len(root2)==len(root1)==215 #they have the same keys True Note: (1) there are persistent dictionaries and lists in the original database_1.fs (2) both of them have the same length and the same indexes.

    Read the article

  • Compress small strings, With what to create external dictionary?

    - by Chris
    I want to compress much small strings (about 75-100 length c# string). At the time the dictionary is created I already know all short strings (nearly a trillion). There will no additional short strings in future. I need to extra exactly one string without decompress other strings. Now I am looking for a library or the best way to do the following: Create a dictionary using all strings I have Using this dictionary to compress each string a way to compress one string using the dictionary from 1. I found a good related question, but this is not c# specific. Maybe there is something for c# I do not know, or a fancy library or someone has already done that. That is the reason I ask this question.

    Read the article

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