Search Results

Search found 8467 results on 339 pages for 'alternate elements'.

Page 9/339 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • CSS/JS: Evenly spreading elements across multiple lines

    - by David Lawson
    How would you go about evenly spreading elements across multiple lines, for example: wrapper div: <div style="text-align: center"> elements inside: <div style="display: inline-block; padding-left: 10px; padding-right: 10px;">Element</div> Instead of only having one element on the next line (wrapped): Element 1 Element 2 Element 3 Element 4 Element 5 Element 6 It does this, spreading out the elements: Element 1 Element 2 Element 3 Element 4 Element 5 Element 6

    Read the article

  • direct access to vector elements similar to arrays

    - by mixm
    hi. im currently creating a tile based game, where elements of the games are placed in four different vectors (since there are multiple game objects with different properties, hence stored in different vectors). these game elements themselves contain x and y coordinates similar to how they are stored in a two dimensional array. i was wondering if there was a way to access these vector elements similar to two dimensional array access (currently i am implementing an for loop to cycle the elements while comparing its coordinates). this kinda sucks when i need to refresh my display at every game cycle (since the large number of comparisons and loops). im implementing this in java btw.

    Read the article

  • filtering elements from list of lists in Python?

    - by user248237
    I want to filter elements from a list of lists, and iterate over the elements of each element using a lambda. For example, given the list: a = [[1,2,3],[4,5,6]] suppose that I want to keep only elements where the sum of the list is greater than N. I tried writing: filter(lambda x, y, z: x + y + z >= N, a) but I get the error: <lambda>() takes exactly 3 arguments (1 given) How can I iterate while assigning values of each element to x, y, and z? Something like zip, but for arbitrarily long lists. thanks, p.s. I know I can write this using: filter(lambda x: sum(x)..., a) but that's not the point, imagine that these were not numbers but arbitrary elements and I wanted to assign their values to variable names.

    Read the article

  • Any Alternate way for writing to a file other than ofstream

    - by Aditya
    Hi All, I am performing file operations (writeToFile) which fetches the data from a xml and writes into a output file(a1.txt). I am using MS Visual C++ 2008 and in windows XP. currently i am using this method of writing to output file.. 01.ofstreamhdr OutputFile; 02./* few other stmts / 03.hdrOutputFile.open(fileName, std::ios::out); 04. 05.hdrOutputFile << "#include \"commondata.h\""<< endl ; 06.hdrOutputFile << "#include \"Commonconfig.h\"" << endl ; 07.hdrOutputFile << "#include \"commontable.h\"" << endl << endl ; 08. hdrOutputFile << "#pragma pack(push,1)" << endl ; 09.hdrOutputFile << "typedef struct \n {" << endl ; 10./ simliar hdrOutputFiles statements... */.. I have around 250 lines to write.. Is any better way to perform this task. I want to reduce this hdrOutputFile and use a buffer to do this. Please guide me how to do that action. I mean, buff = "#include \"commontable.h\"" + "typedef struct \n {" + ....... hdrOutputFile << buff. is this way possible? Thanks Ramm

    Read the article

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

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

    Read the article

  • number of elements in a static array of a predefined size

    - by cppb
    I have an array like this: int a[100]; I am filling only the first 4 elements in this array: a[0] = 1; a[1] = 2; a[2] = 3; a[3] = 4; When I do sizeof(a)/sizeof(a[0]) it returns 100. Is there a way I can get number of elements to which I have assinged a value and thus filtering out the remaining 96 unassigned elements? thanks

    Read the article

  • [ASP.NET] Generating images: Alternate font by User Agent (OS)

    - by sinni800
    Hello, I need to generate small images for certain parts of text. Those will have to fit into the text seamlessly. I know I can not make up for every browser font settings available, but how do I have to check for Linux, Mac and Windows users depending on the user agent? I want to use the right font (of the three "Verdana, Arial, Helvetiva") for the right user agent OS. So: How do I check for the OS? What do I have to compare to in the user agent? Where can I get the other two fonts. Does the Windows-included Verdana look the same as the one used on Linux (or, is it free anyway? I don't know much about fonts)? Where do I get Helvetica? Is it Mac OS licensed? Any code examples can be in either c# or VB.NET. I can read both. Thank you in advance.

    Read the article

  • Getting ID of all elements of a certain class into an array

    - by Tommy Coffee
    Here's what I' trying to do: Currently I am using this to create an array of all elements matching the class name of '.cookie'. Right now I am getting the text value of that element, which is not what I need: var getAllCookies = $('.cookie').text(); var cookiesArray = jQuery.makeArray(getAllCookies); alert(cookiesArray[0]); What I need is to find all elements of a certain class (.cookie), get that elements ID value and store that ID value inside of array.

    Read the article

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

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

    Read the article

  • Disable browser zoom on certain elements in Firefox

    - by Jonathan Morgan
    Is it possible to disable the in-browser, full-page zoom in Firefox (activated by Ctrl +) for a webpage? How about for certain elements in a webpage? I just notice that sometimes elements look really weird when they are zoomed, and it might be nice to just disable the zooming completely for those elements. Note: I know there a few ways to find the zoom level, but this is really wanting to actively work around it (which might not be a good idea anyway).

    Read the article

  • A better solution than element.Elements("Whatever").First()?

    - by codeka
    I have an XML file like this: <SiteConfig> <Sites> <Site Identifier="a" /> <Site Identifier="b" /> <Site Identifier="c" /> </Sites> </SiteConfig> The file is user-editable, so I want to provide reasonable error message in case I can't properly parse it. I could probably write a .xsd for it, but that seems kind of overkill for a simple file. So anyway, when querying for the list of <Site> nodes, there's a couple of ways I could do it: var doc = XDocument.Load(...); var siteNodes = from siteNode in doc.Element("SiteConfig").Element("SiteUrls").Elements("Sites") select siteNode; But the problem with this is that if the user has not included the <SiteUrls> node (say) it'll just throw a NullReferenceException which doesn't really say much to the user about what actually went wrong. Another possibility is just to use Elements() everywhere instead of Element(), but that doesn't always work out when coupled with calls to Attribute(), for example, in the following situation: var siteNodes = from siteNode in doc.Elements("SiteConfig") .Elements("SiteUrls") .Elements("Sites") where siteNode.Attribute("Identifier").Value == "a" select siteNode; (That is, there's no equivalent to Attributes("xxx").Value) Is there something built-in to the framework to handle this situation a little better? What I would prefer is a version of Element() (and of Attribute() while we're at it) that throws a descriptive exception (e.g. "Looking for element <xyz> under <abc> but no such element was found") instead of returning null. I could write my own version of Element() and Attribute() but it just seems to me like this is such a common scenario that I must be missing something...

    Read the article

  • Deserialize Xml with empty elements in C#

    - by user204086
    Trying to deserialize some xml snippits into objects. The problem is that I'm getting an invalid format on every empy element tag. I can deserialize the object no problem when all of the elements have values. Or the empty elements are ommitted. Xml Snippit: <foo><propOne>1</propOne><propTwo /></foo> C# Class: [Serialilbe()] public class foo { public foo(){} [XmlElementAttribute(IsNullable = true)] public int? propOne {get;set;} [XmlElementAttribute(IsNullable = true)] public int? propTwo {get;set;} } Is there a setting on the class I can make to adjust the parsing? or Is there an easy way I can apply xsl to remove these elements? or Should I use regEx to remove the empty elements be fore desrializing? or an even better way?

    Read the article

  • "tail -f" alternate which doesn't scroll the terminal window

    - by Jagtesh Chadha
    I want to check a file at continuous intervals for contents which keep changing. "tail -f" doesn't suffice as the file doesn't grow in size. I could use a simple while loop in bash to the same effect: while [ 1 ]; do cat /proc/acpi/battery/BAT1/state ; sleep 10; done It works, although it has the unwanted effect of scrolling my terminal window. So now I'm wondering, is there a linux/shell command that would display the output of this file without scrolling the terminal?

    Read the article

  • Alternate value of "FeedUri" for contacts entry .

    - by Preeti
    Hi, I am trying to create a contact on Google Apps. I am using Admin credential to create contact in other users in same domain. Problem i am facing is when i use: Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default")); ContactEntry createdEntry = (ContactEntry)service.Insert(feedUri, ContactEntry[0]); It is adding contact in Admin account but i a want to put contact in other user's account. How can i do that? I am using Google Apps API version 2 for .NET. Thanx

    Read the article

  • Linq based generic alternate to Predicate<T>?

    - by Eric
    I have an interface called ICatalog as shown below where each ICatalog has a name and a method that will return items based on a Predicate<Item> function. public interface ICatalog { string Name { get; } IEnumerable<IFamily> GetItems(Predicate<Item> predicate); } A specific implementation of a catalog may be linked to catalogs in various format such as XML, or a SQL database. With an XML catalog I end up deserializing the entire XML file into memory, so testing each item with the predicate function does does not add a whole lot more overhead as it's already in memory. Yet with the SQL implementation I'd rather not retrieve the entire contents of the database into memory, and then filter the items with the predicate function. Instead I'd want to find a way to somehow pass the predicate to the SQL server, or somehow convert it to a SQL query. This seems like a problem that can be solved with Linq, but I'm pretty new to it. Should my interface return IQueryable instead?

    Read the article

  • algorithm to find the three majority elements in an array

    - by Qiang Li
    Let's say there are three elements in a non-sorted array all of which appear more than one-fourth times of the total number of elements. What is the most efficient way to find these elements? Both for non-online and online versions of this question. Thank you! Edit The non-online version I was referring to is: this array is specified in full. The online version means the array elements are coming one at a time. I require the space in addition to time complexity to be tight. disclaimer: THIS IS NOT HOMEWORK! I consider this as research-level question.

    Read the article

  • Remove() not working on new elements [duplicate]

    - by user3317470
    This question already has an answer here: In jQuery, how to attach events to dynamic html elements? 9 answers I'm making a simple to do list. It's mostly working and finished. When you click on list elements the object gets removed and you can create new list elements through the text input at the bottom. The only problem is the new list elements can't be removed when you click them for some reason. Here's the code: http://jsfiddle.net/dnhynh/7psqndwL/20/ $(document).ready(function(){ $("li").click(function(){ $(this).remove(); }); $("button").click(function(){ var entry = $("#entry").val(); $("<li></li>", { text: entry }).appendTo("#list ul"); $("#entry").val(""); }); });

    Read the article

  • Is it possible to use the Raring install image as a package repo (like the old alternate CD)?

    - by jamadagni
    I use Kubuntu and recently upgraded to Raring directly from Precise. Until Precise, I always installed the OS using the alternate CD and not the desktop CD, because I could later on mount the image and use it as an offline package repo. For instance if I remove a package installed by the default installer and later I want to install it again, I can just install it from the ISO without needing to download it again. However, since Quantal the alternate CD no longer exists, so I am not sure how to set up the installed image as a local repo. I mean, doing find . -name "*.deb" inside the ISO tree after loopmounting it only shows a few packages like libc6 gcc and such and not the full set of packages that are actually installed -- I presume they are included in pre-installed form inside casper/filesystem.squashfs. Given this situation, is it or is it not possible to use the Raring install images as offline repos? If yes, how? Thank you!

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >