Search Results

Search found 4616 results on 185 pages for 'lists'.

Page 21/185 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Python dictionary key missing

    - by Greg K
    I thought I'd put together a quick script to consolidate the CSS rules I have distributed across multiple CSS files, then I can minify it. I'm new to Python but figured this would be a good exercise to try a new language. My main loop isn't parsing the CSS as I thought it would. I populate a list with selectors parsed from the CSS files to return the CSS rules in order. Later in the script, the list contains an element that is not found in the dictionary. for line in self.file.readlines(): if self.hasSelector(line): selector = self.getSelector(line) if selector not in self.order: self.order.append(selector) elif selector and self.hasProperty(line): # rules.setdefault(selector,[]).append(self.getProperty(line)) property = self.getProperty(line) properties = [] if selector not in rules else rules[selector] if property not in properties: properties.append(property) rules[selector] = properties # print "%s :: %s" % (selector, "".join(rules[selector])) return rules Error encountered: $ css-combine combined.css test1.css test2.css Traceback (most recent call last): File "css-combine", line 108, in <module> c.run(outfile, stylesheets) File "css-combine", line 64, in run [(selector, rules[selector]) for selector in parser.order], KeyError: 'p' Swap the inputs: $ css-combine combined.css test2.css test1.css Traceback (most recent call last): File "css-combine", line 108, in <module> c.run(outfile, stylesheets) File "css-combine", line 64, in run [(selector, rules[selector]) for selector in parser.order], KeyError: '#header_.title' I've done some quirky things in the code like sub spaces for underscores in dictionary key names in case it was an issue - maybe this is a benign precaution? Depending on the order of the inputs, a different key cannot be found in the dictionary. The script: #!/usr/bin/env python import optparse import re class CssParser: def __init__(self): self.file = False self.order = [] # store rules assignment order def parse(self, rules = {}): if self.file == False: raise IOError("No file to parse") selector = False for line in self.file.readlines(): if self.hasSelector(line): selector = self.getSelector(line) if selector not in self.order: self.order.append(selector) elif selector and self.hasProperty(line): # rules.setdefault(selector,[]).append(self.getProperty(line)) property = self.getProperty(line) properties = [] if selector not in rules else rules[selector] if property not in properties: properties.append(property) rules[selector] = properties # print "%s :: %s" % (selector, "".join(rules[selector])) return rules def hasSelector(self, line): return True if re.search("^([#a-z,\.:\s]+){", line) else False def getSelector(self, line): s = re.search("^([#a-z,:\.\s]+){", line).group(1) return "_".join(s.strip().split()) def hasProperty(self, line): return True if re.search("^\s?[a-z-]+:[^;]+;", line) else False def getProperty(self, line): return re.search("([a-z-]+:[^;]+;)", line).group(1) class Consolidator: """Class to consolidate CSS rule attributes""" def run(self, outfile, files): parser = CssParser() rules = {} for file in files: try: parser.file = open(file) rules = parser.parse(rules) except IOError: print "Cannot read file: " + file finally: parser.file.close() self.serialize( [(selector, rules[selector]) for selector in parser.order], outfile ) def serialize(self, rules, outfile): try: f = open(outfile, "w") for rule in rules: f.write( "%s {\n\t%s\n}\n\n" % ( " ".join(rule[0].split("_")), "\n\t".join(rule[1]) ) ) except IOError: print "Cannot write output to: " + outfile finally: f.close() def init(): op = optparse.OptionParser( usage="Usage: %prog [options] <output file> <stylesheet1> " + "<stylesheet2> ... <stylesheetN>", description="Combine CSS rules spread across multiple " + "stylesheets into a single file" ) opts, args = op.parse_args() if len(args) < 3: if len(args) == 1: print "Error: No input files specified.\n" elif len(args) == 2: print "Error: One input file specified, nothing to combine.\n" op.print_help(); exit(-1) return [opts, args] if __name__ == '__main__': opts, args = init() outfile, stylesheets = [args[0], args[1:]] c = Consolidator() c.run(outfile, stylesheets) Test CSS file 1: body { background-color: #e7e7e7; } p { margin: 1em 0em; } File 2: body { font-size: 16px; } #header .title { font-family: Tahoma, Geneva, sans-serif; font-size: 1.9em; } #header .title a, #header .title a:hover { color: #f5f5f5; border-bottom: none; text-shadow: 2px 2px 3px rgba(0, 0, 0, 1); } Thanks in advance.

    Read the article

  • Pass elements of a list as arguments to a function in python

    - by Wilduck
    I'm building a simple interpreter in python and I'm having trouble handling differing numbers of arguments to my functions. My current method is to get a list of the commands/arguments as follows. args = str(raw_input('>> ')).split() com = args.pop(0) Then to execute com, I check to see if it is in my dictionary of command- code mappings and if it is I call the function I have stored there. For a command with no arguments, this would look like: commands[com]() However, if a command had multiple arguments, I would want this: commands[com](args[0],args[1]) Is there some trick where I could pass some (or all) of the elements of my arg list to the function that I'm trying to call? Or is there a better way of implementing this without having to use python's cmd class?

    Read the article

  • li element background colors and overflow scrolling

    - by user17753
    I created a simple html source, and applied a small CSS style sheet to it: html { width: 100%; } body { font-family: Calibri, Tahoma, Geneva, sans-serif; padding: 20px; } pre { padding: 0; margin: 0 auto; border: 1px solid #888; font-family: Menlo,Monaco,Consolas,monospace; color: #000; width: 80%; overflow: auto; } pre li { white-space: pre; } ol { margin-top: 0; margin-bottom: 0; /* IE indents via margin-left */ color: #979797; background: #E3E3E3; } .li1 { background: #F5F5F5 } .li2 { background: #eee } I have an ordered list inside a pre-formatted tag. Every other list element is either given the class attribute li1 or li2 (the purpose of which is to alternate the colors). The list elements need the white-space: pre because the white space before and after the text node is important. The pre is to be 80% of the containing element (which ends up being 80% of the window's width). In the event of overflow in the x dimension, I want scrolling. I did all this in the above CSS, and it almost works. The issue I am having is that the background colors of the list elements don't extend with the content. They seem to be capped to the original width of the pre and/or ol element as demonstrated in the following picture where I scroll all the way right as possible: I tinkered with the CSS for a while, but I cannot determine the root cause for this or the fix. Looking for some advice on this one, thanks. Complete source with the issue is as below, NOTE: to would-be editors of the below code the pre element is intended to be on a single line as it's pre-formatted text, and formatting it otherwise would change things. <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Test Site</title> <style type="text/css"> html { width: 100%; } body { font-family: Calibri, Tahoma, Geneva, sans-serif; padding: 20px; } pre { padding: 0; margin: 0 auto; border: 1px solid #888; font-family: Menlo,Monaco,Consolas,monospace; color: #000; width: 80%; overflow: auto; } pre li { white-space: pre; } ol { margin-top: 0; margin-bottom: 0; /* IE indents via margin-left */ color: #979797; background: #E3E3E3; } .li1 { background: #F5F5F5 } .li2 { background: #eee } </style> </head> <body> <pre class="php"><ol><li class="li1">pre a &#123; text-decoration: none &#125;</li><li class="li2">pre a:hover &#123; background: #C8C8C8 }</li><li class="li1">pre li &#123; white-space: pre; &#125;</li><li class="li2">&nbsp;</li><li class="li1">.php ol &#123; margin-top: 0; margin-bottom: 0; /* IE indents via margin-left */</li><li class="li2"> color: #979797; background: #E3E3E3; }</li><li class="li1">&nbsp;</li><li class="li2">&nbsp;</li><li class="li1">&nbsp;</li><li class="li2">.php .li1 &#123; background: #F5F5F5 }</li><li class="li1">.php .li2 &#123; background: #eee }</li><li class="li2">&nbsp;</li><li class="li1">&nbsp;</li><li class="li2">.php .st0 &#123; color: #C0C } /* string content */</li><li class="li1">.php .st_h &#123; color: #F0C } /* string content single quoted */</li><li class="li2">.php .sy0 &#123; color: #000 } /* semi-colon, operators */ </li><li class="li1">.php .br0 &#123; color: #000 } /* parens */</li><li class="li2">.php .kw2 &#123; color: #00F } /* php tags */</li><li class="li1">.php .sy1 &#123; color: #00F } /* php tags */</li><li class="li2">.php .nu0 &#123; color: #F00 } /* numbers */</li><li class="li1">.php .kw3 &#123; color: #096 } /* core language functions */</li><li class="li2">.php .re0 &#123; color: #09F; font-weight: bold; } /* variables */</li><li class="li1">.php .kw1 &#123; color: #069; font-weight: bold; } /* control statements? */</li><li class="li2">.php .kw4 &#123; color: #069; font-weight: bold; } /* bool? */</li><li class="li1">.php .co1 &#123; color: #FF8400 } /* Forward slash comments */</li></ol></pre> </body> </html>

    Read the article

  • Python: Indexing list for element in nested list

    - by aquateenfan
    I know what I'm looking for. I want python to tell me which list it's in. Here's some pseudocode: item = "a" nested_list = [["a", "b"], ["c", "d"]] list.index(item) #obviously this doesn't work here I would want python to return 0 (because "a" is an element in the first sub-list in the bigger list). I don't care which sub-element it is. I don't care if there are duplicates, e.g., ["a", "b", "a"] should return the same thing as the above example. Sorry if this is a dumb question. I'm new to programming.

    Read the article

  • How to drill down with jQuery?

    - by Timothy Reed
    I'm new to jQuery so sorry if this sounds stupid but I'm having truble drilling down to other elemnts. Paticularly I want to fade in the .menu li a:hover class with jquery. .menu { padding:0; margin:0; list-style:none; } .menu li { float:left; margin-left:1px; } .menu li a { display:block; height:44px; line-height:40px; padding:0 5px; float:right; color:#fff; text-decoration:none; font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif; font-size:12px; font-weight:bold; } .menu li a b { text-transform:uppercase; } .menu li a:hover { color:#E4FFC5; background: url(../images/arrow.png) no-repeat center bottom; } .current { background: url(../images/arrow.png) no-repeat center bottom; font-size:16px; font-weight:bold; } .spacer p { display:block; height:44px; line-height:40px; padding:0 5px; float:right; color:#fff; text-decoration:none; font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif; font-size:12px; font-weight:bold; } <ul class="menu"> <li class="current"><a href="index.html">Home</a></li> <li class="spacer"> <p>|</p> </li> <li><a href="#">Mission &amp; Values </a></li> <li class="spacer"> <p>|</p> </li> <li><a href="#">Caregivers</a></li> <li class="spacer"> <p>|</p> </li> <li><a href="#">Special Programs </a></li> <li class="spacer"> <p>|</p> </li> <li><a href="#">Enployment</a></li> <li class="spacer"> <p>|</p> </li> <li><a href="#">Contact</a></li> </ul> <script type="text/javascript"> $(function() { $('a').mouseover(function() { $('.logo').animate ({opacity:'0.6'}, 'normal'); }); $('a').mouseout (function() { $('.logo').animate ({opacity:'1'}, 'normal'); $('.menu li a:hover').fadeIn ('slow'); }); </script>

    Read the article

  • clear div clearing the page to the end in jquery ui tabs...

    - by Pradyut Bhattacharya
    I have set up a list using this css... #navlist li { list-style-type: none; padding: 7px; float: left; } I have shown the page using jquery ui with other div containers... the page here the page named friend.jsp?all=true Im using a clearing div... .clear { clear:left; overflow:hidden; height:1px; } Now when i use a clearing div i get the page like this... the clearing div is clearing up to the end of the page... but on the 1st tab, that is on the freinds tab, when i m not using a clearing div i get the tab pane with no height... Any help with setting up a css for ui tabs or with setting up the list without float:left thanks Pradyut

    Read the article

  • How to switch position of two items in a Python list?

    - by mikl
    I haven’t been able to find a good solution for this problem on the net (probably because switch, position, list and Python are all such overloaded words). It’s rather simple – I have this list: ['title', 'email', 'password2', 'password1', 'first_name', 'last_name', 'next', 'newsletter'] I’d like to switch position of 'password2' and 'password1' – not knowing their exact position, only that they’re right next to one another and password2 is first. I’ve accomplished this with some rather long-winded list-subscripting, but I wondered if someone could come up with something a bit more elegant?

    Read the article

  • Easy way to check if item is in list?

    - by befall
    Hey guys, I'm writing a search algorithm in C++, and one of the things I need to do is have a few if statements that check cells above, below, left of, and right of. Each time a cell is found to be open and added to the stack, I want it added to a list of cells already checked. I want to be able to say in the if loop if(thisCell is not in checkedCells). Any simple ideas? Thanks!

    Read the article

  • click li, go to next li

    - by steve
    Can't find a simple solution to this, I know it's easy and I've tried a few things but I can't quite get it to work. I'm currently working with a sidescrolling site and I want every time you click an image (contained in an li) it scrolls to the next li. I have jQuery plugin localscroll so it smoothly goes from one to the next, and that's working. I need to now write a code that triggers jQuery to utilize the localscroll function and go to the next li. Right now I have this, but I know it's not right: $(document).ready(function () { var gallery = $('.wrapper ul li') $(gallery).click(function() { $.localscroll().next(li); }); });

    Read the article

  • Linked List Sorting with Strings In C

    - by user308583
    I have a struct, with a Name and a single Node called nextName It's a Singly Linked list, and my task is to create the list, based on alphabetical order of the strings. So iff i enter Joe Zolt and Arthur i should get my list structured as Joe Than Joe Zolt Than Arthur Joe Zolt I'm having trouble implementing the correct Algorithm, which would put the pointers in the right order. This is What I have as of Now. Temp would be the name the user just entered and is trying to put into the list, namebox is just a copy of my root, being the whole list if(temp != NULL) { struct node* namebox = root; while (namebox!=NULL && (strcmp((namebox)->name,temp->name) <= 0)) { namebox = namebox->nextName; printf("here"); } temp->nextName = namebox; namebox = temp; root = namebox; This Works right now, if i enter names like CCC BBB than AAA I Get Back AAA BBB CCC when i print But if i put AAA BBB CCC , When i print i only get CCC, it cuts the previous off.

    Read the article

  • not able to get a processed list in jquery variable

    - by Pradyut Bhattacharya
    I have html list <ol id="newlist"> <li>Test <ol> <li>1</li> <li>2</li> <li>3</li> </ol> </li> <li>Another test <ol> <li>1</li> </ol> </li> <li>Cool Test <ol> <li>1</li> <li>2</li> </ol> </li> </ol> Now i have hidden the list using the css... #newlist li { display:none; list-style: none; } I want to display the list and the only the descendants which have greater than 1 descendants... the output should be... Test 1 2 3 Another test Cool Test 1 2 I have used jquery and able to get the output... the code i used... $("ol#newlist > li").show(); for (var i = 0; i < $("ol#newlist > li").length; i++) { if ($("ol#newlist > li:eq(" + i + ") ol > li").length > 1) $("ol#newlist > li:eq(" + i + ") ol > li").show(); } the sample page here Now i want all the list in a single variable like i can get the lis in a variable... var $li = $("ol#newlist > li"); but the code $li.add($("ol#newlist > li:eq(" + i + ") ol > li")); is not working... the sample page here Please help... Thanks Pradyut India

    Read the article

  • Creating a list in Python- something sneaky going on?

    - by GlenCrawford
    Apologies if this doesn't make any sense, I'm very new to Python! From testing in an interpreter, I can see that list() and [] both produce an empty list: >>> list() [] >>> [] [] From what I've learned so far, the only way to create an object is to call its constructor (__init__), but I don't see this happening when I just type []. So by executing [], is Python then mapping that to a call to list()?

    Read the article

  • jQuery How do I move an element inside of another element

    - by TripWired
    Hi I'm using grails navigation plugin and when it generates menus it put the sub navigation underneath the main menu, but i'm making my menu a vertical menu so i don't want the sub menu under the whole menu i want it under the active element. Example: this is how it generate the menu and sub menu <ul class="mainmenu"> <li>item1</li> <li>item2</li> <li>item3</li> </ul> <ul class="submenu"> <li>item1</li> <li>item2</li> <li>item3</li> </ul> What i want is: <ul class="mainmenu"> <li>item1 <ul class="submenu"> <li>item1</li> <li>item2</li> <li>item3</li> </ul> </li> <li>item2</li> <li>item3</li> </ul> Since i don't know of a way to make grails nav plugin do this i guess i'll have to make jquery do it after it's generated. Any ideas?

    Read the article

  • How do I use xStream to output Java Objects with List properties?

    - by Zachary Spencer
    Hello, I am trying to output some Java objects as JSON, they have List properties which I want to be formatted as { "People" : [ { "Name" : "Bob" } , { "Name" : "Jim" } ] } However, I cannot figure out how to do this with XStream. It always outputs as { "Person" : { "Name" : "Bob" }, "Person" : { "Name" : "Bob" } Is there a way to fix this? I've put together some sample code with a unit test in github if you need something more concrete to play with: http://gist.github.com/371358 Thanks!

    Read the article

  • unable to apply jquery filter

    - by Pradyut Bhattacharya
    Hi I m un-animating a list using this code... function unanimate_li(){ $li.filter(':last') .animate({ height: 'hide', opacity: 'hide' }, 1000, function(){ unanimate_li(); }); $li = $li.not(':last'); } I have set up the li using this code $li = $("ol#update > li"); $li = $li.filter(':gt(4)').filter(':lt('+ size + ')'); Now when i try to do this i cannot get the 5th li(4th on zero based) to remove It removes the sixth li The example here And when the second time i do the update it goes on to infinite loop I cannot understand why

    Read the article

  • Why doesn't this image sprite menu display properly, and why aren't the links working?

    - by briligg
    The code validates. There should be two more images in the menu on the left, above the visible one of the silo. And each should be a link. http://www.briligg.com/agnosticism.html css is: external style sheet: .menu { position: relative; float: left; margin: 10px; padding: 0; width: 150px; } .menu li { margin: 0; padding: 0; list-style: none; position: absolute; left: 0; top: 260px; } .menu li, .menu a { width: 150px; height: 150px; } internal style sheet: .menu { height: 450px; } .mirror { top: 0; } .mirror { background: url(http://www.briligg.com/images/menu-ag.png) 0 0; } .wormcan { top: 151px; } .wormcan { background: url(http://www.briligg.com/images/menu-ag.png) 0 -151px; } .wormsilo { top: 301px; } .wormsilo { background: url(http://www.briligg.com/images/menu-ag.png) 0 -301px; } html: <ul class="menu"> <li class="mirror"> <a href="whoryou.html"></a> </li> <li class="wormcan"> <a href="aroundyou.html"></a> </li> <li class="wormsilo"> <a href="beyondyou.html"></a> </li> </ul>

    Read the article

  • Create list of variable type

    - by Jan
    I am trying to create a list of a certain type. I want to use the List notation but all I know is a "System.Type" The type a have is variable. How can I create a list of a variable type? I want something similar to this code. public IList createListOfMyType(Type myType) { return new List<myType>(); }

    Read the article

  • Bullets WILL NOT dissapear in firefox

    - by DunlopBurns
    Hoping you can help me with a problem. I cannot get rid of Bullets in Firefox, i don't want any anywhere, hence my list-style-type: none!important being everywhere. It only appears in Firefox as far as i can tell. the HTML.... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>littleprints.nl</title> <meta name="description" content="----" /> <meta name="keywords" content="----" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript" src="js/slimbox2.js"></script> <link rel="stylesheet" href="css/slimbox2.css" type="text/css" media="screen" /> <link rel="stylesheet" href="layout.css"/> <link rel="stylesheet" href="style.css"/> </head> <body> <div id="container"> <div id="inline1"> <div id="mainpic"> <img src="myimages/circle.jpg" width="100%" alt="Circle bracelet"/> </div> <div id="intro"> <p>Hi and welcome to little prints NL. we make this and that all by hand with 100% silver. my name is Donna Burns and i work by commision, ive been studying for 4 years and am currently learning to become a goldsmith.</p> </div> </div> <div id="inline2"> <p>Click for more...</p> <div id="images"> <a href="myimages/photos/dogtag.jpg" rel="lightbox-gal" title="Beautiful, isn't it?" ><img src="myimages/work/chunky.gif" alt="chunky"/></a> <a href="myimages/photos/hearts.jpg" rel="lightbox-gal" title="Beautiful, isn't it?" ><img src="myimages/work/hearts.gif" alt="hearts"/></a> <a href="myimages/photos/close.jpg" rel="lightbox-gal" title="Beautiful, isn't it?" ><img src="myimages/work/close.gif" alt="close"/></a> <a href="myimages/photos/pearl.jpg" rel="lightbox-gal" title="Beautiful, isn't it?" >&nbsp;</a> <a href="myimages/photos/flower.jpg" rel="lightbox-gal" title="Beautiful, isn't it?" >&nbsp;</a> <a href="myimages/photos/frontcircle.jpg" rel="lightbox-gal" title="Beautiful, isn't it?" >&nbsp;</a> <a href="myimages/photos/dogtag.jpg" rel="lightbox-gal" title="Beautiful, isn't it?" >&nbsp;</a> </div> </div> </div><!--end container--> <div id="footer"> <div id="footalign"> <div id="social"> <ul> <li> <a href="http://www.facebook.com/littleprints" title="Little Prints"> <img src="myimages/facebook.png" width="50px" height="50px" alt="FB"/> </a> </li> <li> <a href="contact.html" title="contact"> <img src="myimages/at.gif" alt="@"/> </a> </li> </ul> </div> <div id="contact"> <p><br/>To enquire about a charm either phone:<br/> 0787463289<br/> or use one of the methods to the side.</p> </div> </div> </div> </body> </html> the CSS... * {margin: 0; padding: 0; border: 0;} html, body { background-color: #000000;image; text-align: center; font: 16px/1.8 Verdana, Arial, Helvetica, sans-serif; list-style-type: none!important; text-decoration: none;} #container { position: relative; width: 900px; top: 0; min-height: 100%; margin-left: auto; margin-right: auto; padding-top: 20px; background-image: URL(myimages/back2.gif); margin-bottom: 180px; } #footer { background-color: #555555; position: relative; clear: both; bottom: 0; width: 900px; height: auto; margin-left: auto; margin-right: auto; margin-bottom: 20px; padding-bottom: 22px; margin-top: -180px; } #inline1{ display: inline-block; margin-top: 250px; margin-bottom: 20px; } #inline2 { display: inline-block; margin-top: 30px; margin-bottom: 50px; } #mainpic { float: left; width: 68%; margin-left: 20px; } #intro { float: right; width: 20%; margin-left: auto; margin-right: 50px; margin-top: 20px; } #images { margin-bottom: 20px; margin-left: auto; margin-right: auto; } #footalign { display: inline; width:900px; list-style-type: none; } #contact { text-align: center; background-color:#555555; float: middle; list-style-type: none; } #social{ background-color:#555555; float: right; list-style: none; padding:0; padding-right: 5px; text-align:center; list-style-type: none!important; } #social img{ border: none; list-style-type: none!important; margin: 3px; } #social ul{ border: none; list-style-type: none!important; } #social a{ display:inline-block; -webkit-transition:all .5s ease-out; -moz-transition:all .5s ease-out; -ms-transition:all .5s ease-out; -o-transition:all .5s ease-out; transition:all .5s ease-out; list-style-type: none!important; } #social a:hover{ display:inline-block; -webkit-transform:translate(-10px,0px); -moz-transform:translate(0px,-10px); -ms-transform:translate(-10px,0px); -o-transform:translate(-10px,0px); transform:translate(-10px,0px); list-style-type: none!important; } #form { margin-top: 250px; margin-bottom: 50px; } .nav1 {font-family: sans-serif;font-size: 22px;text-shadow: 2px 2px 5px #000000;} a:link {text-decoration:none; color:#000000; padding:3px;} a:visited {text-decoration:none; color:#000000;} a:active {text-decoration:none; color:#555555;} a:hover {text-decoration:none; color:#555555;} .nav2 {font-family: sans-serif;font-size: 22px;text-shadow: 2px 2px 5px #ffffff;} a:link {text-decoration:none; color:#ffffff; padding:3px;} a:visited {text-decoration:none; color:#ffffff;} a:active {text-decoration:none; color:#555555;} a:hover {text-decoration:none; color:#555555;} .p1 { color: #ffffff; } div#images img { max-width: 500px; height: auto; }

    Read the article

  • Efficient data structure for fast random access, search, insertion and deletion

    - by Leonel
    I'm looking for a data structure (or structures) that would allow me keep me an ordered list of integers, no duplicates, with indexes and values in the same range. I need four main operations to be efficient, in rough order of importance: taking the value from a given index finding the index of a given value inserting a value at a given index deleting a value at a given index Using an array I have 1 at O(1), but 2 is O(N) and insertion and deletions are expensive (O(N) as well, I believe). A Linked List has O(1) insertion and deletion (once you have the node), but 1 and 2 are O(N) thus negating the gains. I tried keeping two arrays a[index]=value and b[value]=index, which turn 1 and 2 into O(1) but turn 3 and 4 into even more costly operations. Is there a data structure better suited for this?

    Read the article

  • Python: Get items at depth? (set library?)

    - by Mark
    I have a nested list something like this: PLACES = ( ('CA', 'Canada', ( ('AB', 'Alberta'), ('BC', 'British Columbia' ( ('van', 'Vancouver'), ), ... )), ('US', 'United States', ( ('AL', 'Alabama'), ('AK', 'Alaska'), ... I need to retrieve some data out of it. If depth is 0 I need to retrieve all the countries (and their codes), if depth == 1, I need to retrieve all the states/provinces, if depth == 2 I need to retrieve all the cities... and so forth. Is there some set library for doing stuff like this? Or can someone point me in the right direction? I started coding up a solution only to realize it wouldn't work for levels deeper than 1 because you have to go in and out of each list...

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >