Search Results

Search found 86 results on 4 pages for 'oranges'.

Page 1/4 | 1 2 3 4  | Next Page >

  • Apples, oranges, and pointers to the most derived c++ class

    - by Matthew Lowe
    Suppose I have a bunch of fruit: class Fruit { ... }; class Apple : public Fruit { ... }; class Orange: public Fruit { ... }; And some polymorphic functions that operate on said fruit: void Eat(Fruit* f, Pesticide* p) { } void Eat(Apple* f, Pesticide* p) { ingest(f,p); } void Eat(Orange* f, Pesticide* p) { peel(f,p); ingest(f,p); } OK, wait. Stop right there. Note at this point that any sane person would make Eat() a virtual member function of the Fruit classes. But that's not an option, because I am not a sane person. Also, I don't want that Pesticide* in the header file for my fruit class. Sadly, what I want to be able to do next is exactly what member functions and dynamic binding allow: typedef list<Fruit*> Fruits; Fruits fs; ... for(Fruits::iterator i=fs.begin(), e=fs.end(); i!=e; ++i) Eat(*i); And obviously, the problem here is that the pointer we pass to Eat() will be a Fruit*, not an Apple* or an Orange*, therefore nothing will get eaten and we will all be very hungry. So what I really want to be able to do instead of this: Eat(*i); is this: Eat(MAGIC_CAST_TO_MOST_DERIVED_CLASS(*i)); But to my limited knowledge, such magic does not exist, except possibly in the form of a big nasty if-statement full of calls to dynamic_cast. So is there some run-time magic of which I am not aware? Or should I implement and maintain a big nasty if-statement full of dynamic_casts? Or should I suck it up, quit thinking about how I would implement this in Ruby, and allow a little Pesticide to make its way into my fruit header?

    Read the article

  • mongodb php finding a subobject and removing it, $inc other subobject

    - by Mark
    I'm trying to delete the subobject 'apples' from my documents and update the 'fruitInventory' property, decrease by the amount of apples. I'm confused on how to proceed, should I use dot notation or do a full text search for apples? I don't know if this matters but you can assume apples will always be in field 1. // Document 1 { "1": { "apples": 3, "fruitInventory": 21, "oranges": 12, "kiwis": 3, "lemons": 3 }, "2": { "bananas": 4, "fruitInventory": 12, "oranges": 8, }, "_id": "1" } // Document 2 { "1": { "apples": 5, "fruitInventory": 10, "oranges": 2, "pears": 3 }, "2": { "bananas": 4, "fruitInventory": 6, "cherries": 2, }, "_id": "2" } Result should be like this: // Document 1 { "1": { "fruitInventory": 18, "oranges": 12, "kiwis": 3, "lemons": "3" }, "2": { "bananas": 4, "fruitInventory": 12, "oranges": 8, }, "_id": "1" } // Document 2 { "1": { "fruitInventory": 5, "oranges": "2", "pears": "3" }, "2": { "bananas": 4, "fruitInventory": 6, "cherries": 2, }, "_id": "2" } Thanks in advance for your help.

    Read the article

  • Is there any way to optimize this LINQ where clause that searches for multiple keywords on multiple

    - by Daniel T.
    I have a LINQ query that searches for multiple keywords on multiple columns. The intention is that the user can search for multiple keywords and it will search for the keywords on every property in my Media entity. Here is a simplified example: var result = repository.GetAll<Media>().Where(x => x.Title.Contains("Apples") || x.Description.Contains("Apples") || x.Tags.Contains("Apples") || x.Title.Contains("Oranges") || x.Description.Contains("Oranges") || x.Tags.Contains("Oranges") || x.Title.Contains("Pears") || x.Description.Contains("Pears") || x.Tags.Contains("Pears") ); In other words, I want to search for the keywords Apples, Oranges, and Pears on the columns Title, Description, and Tags. The outputted SQL looks like this: SELECT * FROM Media this_ WHERE (((((((( this_.Title like '%Apples%' or this_.Description like '%Apples%') or this_.Tags like '%Apples%') or this_.Title like '%Oranges%') or this_.Description like '%Oranges%') or this_.Tags like '%Oranges%') or this_.Title like '%Pears%') or this_.Description like '%Pears%') or this_.Tags like '%Pears%') Is this the most optimal SQL in this case? If not, how do I rewrite the LINQ query to create the most optimal SQL statement? I'm using SQLite for testing and SQL Server for actual deployment.

    Read the article

  • Efficient way in Python to add an element to a comma-separated string

    - by ensnare
    I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words: For example: string = 'Apples, Bananas, Grapes, Oranges' addition = 'Cherries' result = 'Apples, Bananas, Cherries, Grapes, Oranges' Also, a way to do this but while maintaining IDs: string = '1:Apples, 4:Bananas, 6:Grapes, 23:Oranges' addition = '62:Cherries' result = '1:Apples, 4:Bananas, 62:Cherries, 6:Grapes, 23:Oranges' Sample code is greatly appreciated. Thank you so much.

    Read the article

  • Efficient way in Python to remove an element from a comma-separated string

    - by ensnare
    I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words: For example: string = 'Apples, Bananas, Grapes, Oranges' subtraction = 'Bananas' result = 'Apples, Grapes, Oranges' Also, a way to do this but while maintaining IDs: string = '1:Apples, 4:Bananas, 6:Grapes, 23:Oranges' subtraction = '4:Bananas' result = '1:Apples, 6:Grapes, 23:Oranges' Sample code is greatly appreciated. Thank you so much.

    Read the article

  • Lenovo Ideapad 205 and Ubuntu 12.04 LTS

    - by Oranges
    I just wanted to report one thing, because I know there are a lot of Ideapad S205 users out there, that had issues running Ubuntu on their Lenovo Ideapad S205 in the past. Lenovo Ideapad with Ubuntu 12.04 LTS: Everything works out of the box. I just installed it and everything, including the microphone, the webcam, the WLAN, the AMD E-350 CPU/GPU and the sound worked right away. In other words: Everything works. Even the AMD E-350 GPU works very well with the Open Source drivers and with the prop. drivers. The prop. drivers were automatically offered to me via Ubuntu itself. It works great. A long idea, written short: I love it. It's extremly stable and very fast. I am using the German version of the Idepad S205, combined with the 32bit version of Ubuntu. There is only one, single thing to keep in mind when installing Ubuntu on the S205: Plugin your USB/CD/DVD drive in the left USB-Port. I don't know why, but it only works with the USB-Port on the left side of the Netbook. This is only for installing Ubuntu. After it has been installed and updated successfully, all of the USB ports will work. Oranges - feedback on Lenovo S205 with Ubuntu 12.04 LTS.

    Read the article

  • Is Adobe Flash 11.2 working with Nvidia hardware again in 12.04?

    - by Oranges
    I installed the newest Nvidia-Linux drivers version number 304.43 on 12.04 installation and all Flash Videos now show me "accelerated video rendering". Previous Nvidia drivers + Adobe Flash only rendered in software, at least since Adobe officially said they turned off "hardware acceleration" for Linux, because of unstable and unsecure drivers. Has this changed? Is hardware acceleration really back? Can anyone verify this as well? The Nvidia driver 304.43 patch notes said: Fixed a bug that caused VDPAU to hang when expanding the YouTube Flash Player. Hardware: Nvidia 8600M GT

    Read the article

  • Relational vs. Dimensional Databases, what's the difference?

    - by grautur
    I'm trying to learn about OLAP and data warehousing, and I'm confused about the difference between relational and dimensional modeling. Is dimensional modeling basically relational modeling, but allowing for redundant/un-normalized data? For example, let's say I have historical sales data on (product, city, # sales). I understand that the following would be a relational point-of-view: Product | City | # Sales Apples, San Francisco, 400 Apples, Boston, 700 Apples, Seattle, 600 Oranges, San Francisco, 550 Oranges, Boston, 500 Oranges, Seattle, 600 While the following is a more dimensional point-of-view: Product | San Francisco | Boston | Seattle Apples, 400, 700, 600 Oranges, 550, 500, 600 But it seems like both points of view would nonetheless be implemented in an identical star schema: Fact table: Product ID, Region ID, # Sales Product dimension: Product ID, Product Name City dimension: City ID, City Name And it's not until you start adding some additional details to each dimension that the differences start popping up. For instance, if you wanted to track regions as well, a relational database would tend to have a separate region table, in order to keep everything normalized: City dimension: City ID, City Name, Region ID Region dimension: Region ID, Region Name, Region Manager, # Regional Stores While a dimensional database would allow for denormalization to keep the region data inside the city dimension, in order to make it easier to slice the data: City dimension: City ID, City Name, Region Name, Region Manager, # Regional Stores Is this correct?

    Read the article

  • Use Struct as a Ptr/class? Need a fix .NET

    - by acidzombie24
    I wrote a bunch of code and i would like to fix it the fastest way possible. I'll describe my problem in a easier way. I have apples and oranges, they are both Point and in the list apples, oranges. I create a PictureBox and draw the apple/oranges on screen and move them around and update the Point via Tag. The problem now is since its a struct the tag is a copy so the original elements in the list are not update. So, how do i update them? I consider using Point? But those seem to be readonly. So the only solution i can think of is Clear the list, iterate through all the controls then check the picturebox property to check if the image is a apple or orange then add it to a list I really only thought of this solution typing this question, but my main question is, is there a better way? Is there some List<Ptr<Point>> class i can use so when i update the apples or oranges through the tag the element in the list will update as a class would?

    Read the article

  • How to replace all instances of a particular value in a mysql database with another?

    - by Joseph
    I'm looking for a MySQL equivalent of what str_replace is for PHP. I want to replace all instances of one word with another, I want to run a query that will replace all "apples" with "oranges". The reason why: UPDATE fruits SET name='oranges' WHERE name='apples'; isn't going to work for my situation, is because I often times have multiple words in a table row separated by commas like: "apples, pears, pineapples". In this case I want just apples to be replaced by oranges and pear and pineapples to stay in tact. Is there any way to do this?

    Read the article

  • Base-camp Style Subdomains and IDs of Models

    - by Newy
    I have an app that has Basecamp-style subdomains, that is, I have Projects, Users, Apples and Oranges. The Users, Apples and Oranges are all keyed to a Project and only exist in the http://project.myapp.com. I added a project_id to Users, Apples and Oranges and everything works, except of course that the ids of those three objects increment globally, and throughout my app I lookup objects by that id. This doesn't seem like best practice. Should I instead do lookups by a secondary key? How does that affect efficiency? If there's a good blog post that covers this, would be wesome.

    Read the article

  • How to combine two sql queries?

    - by plasmuska
    Hi Guys, I have a stock table and I would like to create a report that will show how often were items ordered. "stock" table: item_id | pcs | operation apples | 100 | order oranges | 50 | order apples | -100 | delivery pears | 100 | order oranges | -40 | delivery apples | 50 | order apples | 50 | delivery Basically I need to join these two queries together. A query which prints stock balances: SELECT stock.item_id, Sum(stock.pcs) AS stock_balance FROM stock GROUP BY stock.item_id; A query which prints sales statistics SELECT stock.item_id, Sum(stock.pcs) AS pcs_ordered, Count(stock.item_id) AS number_of_orders FROM stock GROUP BY stock.item_id, stock.operation HAVING stock.operation="order"; I think that some sort of JOIN would do the job but I have no idea how to glue queries together. Desired output: item_id | stock_balance | pcs_ordered | number_of_orders apples | 0 | 150 | 2 oranges | 10 | 50 | 1 pears | 100 | 100 | 1 This is just example. Maybe, I will need to add more conditions because there is more columns. Is there a universal technique of combining multiple queries together?

    Read the article

  • NSString stringWithFormat question

    - by John Smith
    I am trying to build a small table using NSString. I cannot seem to format the strings properly. Here is what I have [NSString stringWithFormat:@"%8@: %.6f",e,v] where e is an NSString from somewhere else, and v is a float. What I want is output something like this: Grapes: 20.3 Pomegranates: 2.5 Oranges: 15.1 What I get is Grapes:20.3 Pomegranates:2.5 Oranges:15.1 How can I fix my format to do something like this?

    Read the article

  • Using excel, how can I count the number of cells in a column containing the text "true" or "false"?

    - by Jay Elston
    I have a spreadsheet that has a column of cells where each cell contains a single word. I would like to count the occurrences of some words. I can use the COUNTIF function for most words, but if the word is "true" or "false", I get 0. A B 1 apples 2 2 true 0 3 false 0 4 oranges 1 5 apples In the above spreadsheet table, I have these formulas in cells B1, B2, B3 and B4: =COUNTIF(A1:A5,"apples") =COUNTIF(A1:A5,"true") =COUNTIF(A1:A5,"false") =COUNTIF(A1:A5,"oranges) As you can see, I can count apples, but not true or false. I have also tried this: =COUNTIF(A1:A5,TRUE) But that does not work either. Note -- I am using Excel 2007.

    Read the article

  • IVR-style dialog system

    - by unbeli
    I need to build a dialog system similar to IVR used in call centers. My system is not phone-based, but the dialog is similar. Something like System: "Main menu: Enter [1] for menu1, [2] for menu2" User: [1] System: "menu1: enter [1] for apples, [2] for oranges, [3] for main menu" User: [7] System: "What??" System: "menu1: enter [1] for apples, [2] for oranges, [3] for main menu" User: [2] ... and so on I want to have a nice declarative description of all the possible options and a nice way to run through that tree, guided by user input. Already considered: ANTLR-generated lexer/parser (seems to be an overkill), SCXML-based state machine (seems like only transitions can be declared, the rest needs to be coded)

    Read the article

  • IVR-style dialog system / workflow / menu

    - by unbeli
    I need to build a dialog system similar to IVR used in call centers. My system is not phone-based, but the dialog is similar. Something like System: "Main menu: Enter [1] for menu1, [2] for menu2" User: [1] System: "menu1: enter [1] for apples, [2] for oranges, [3] for main menu" User: [7] System: "What??" System: "menu1: enter [1] for apples, [2] for oranges, [3] for main menu" User: [2] ... and so on I want to have a nice declarative description of all the possible options and a nice way to run through that tree, guided by user input. Already considered: ANTLR-generated lexer/parser (seems to be an overkill), SCXML-based state machine (seems like only transitions can be declared, the rest needs to be coded)

    Read the article

  • Find order of data inside an array

    - by user271619
    I have a simple array of stuff: $array = array("apples","oranges","strawberries"); I am trying to find the order of the stuff inside the array. (sometimes the order changes, and so do the items) I'm expecting to get something like this: "apples" = 0, "oranges = 1, "strawberries = 2 The end result has something to do with database sorting. Something like this, inside a foreach loop: UPDATE tbl SET sortorder = $neworder WHERE fruit = '$fruitname' The $neworder variable would be populated with the new order, inside the array. While the $fruit variable comes from the item inside the array.

    Read the article

  • Overriding rubies spaceship operator <=>

    - by ericsteen1
    I am trying to override rubies <= (spaceship) operator to sort apples and oranges so that apples come first sorted by weight, and oranges second, sorted by sweetness. Like so: module Fruity attr_accessor :weight, :sweetness def <=>(other) # use Array#<=> to compare the attributes [self.weight, self.sweetness] <=> [other.weight, other.sweetness] end include Comparable end class Apple include Fruity def initialize(w) self.weight = w end end class Orange include Fruity def initialize(s) self.sweetness = s end end fruits = [Apple.new(2),Orange.new(4),Apple.new(6),Orange.new(9),Apple.new(1),Orange.new(22)] p fruits #should work? p fruits.sort But this does not work, can someone tell what I am doing wrong here, or a better way to do this?

    Read the article

  • How do I save a transient object that already exists in an NHibernate session?

    - by Daniel T.
    I have a Store that contains a list of Products: var store = new Store(); store.Products.Add(new Product{ Id = 1, Name = "Apples" }; store.Products.Add(new Product{ Id = 2, Name = "Oranges" }; Database.Save(store); Now, I want to edit one of the Products, but with a transient entity. This will be, for example, data from a web browser: // this is what I get from the web browser, this product should // edit the one that's already in the database that has the same Id var product = new Product{ Id = 2, Name = "Mandarin Oranges" }; store.Products.Add(product); Database.Save(store); However, trying to do it this way gives me an error: a different object with the same identifier value was already associated with the session How do I get around this problem?

    Read the article

  • What question(s) does an object's behavior answer?

    - by Corwin
    Reading a book I have found the following statement: (Object) Behaviors answer either of two questions: What does this object do (for me)? or What can I do to this object? In the case of an orange, it doesn’t do a whole lot, but we can do things to it. One behavior is that it can be eaten. In my understanding of object behaviour the statement above is correct regarding the first question and is incorrect in case of the second. However, I often see classes with methods like Orange::eat(), and this makes me uncertain about my design skills. So I would like to ask is it a design mistake to give oranges a behaviour eat? (oranges and eat are used just for example)

    Read the article

  • Overriding Ruby's spaceship operator <=>

    - by ericsteen1
    I am trying to override Ruby's <= (spaceship) operator to sort apples and oranges so that apples come first sorted by weight, and oranges second, sorted by sweetness. Like so: module Fruity attr_accessor :weight, :sweetness def <=>(other) # use Array#<=> to compare the attributes [self.weight, self.sweetness] <=> [other.weight, other.sweetness] end include Comparable end class Apple include Fruity def initialize(w) self.weight = w end end class Orange include Fruity def initialize(s) self.sweetness = s end end fruits = [Apple.new(2),Orange.new(4),Apple.new(6),Orange.new(9),Apple.new(1),Orange.new(22)] p fruits #should work? p fruits.sort But this does not work, can someone tell what I am doing wrong here, or a better way to do this?

    Read the article

  • Using excel, how can I count the number of cells in a column containing the text "true" or "false"?

    - by Jay Elston
    I have a spreadsheet that has a column of cells where each cell contains a single work. I would like to count the occurrences of some words. I can use the COUNTIF function for most words, but if the word is "true" or "false", I get 0. A B 1 apples 2 2 true 0 3 false 0 4 oranges 1 5 apples In the above spreadsheet table, I have these formulas in cells B1, B2, B3 and B4: =COUNTIF(A1:A5,"apples") =COUNTIF(A1:A5,"true") =COUNTIF(A1:A5,"false") =COUNTIF(A1:A5,"oranges) As you can see, I can count apples, but not true or false. I have also tried this: =COUNTIF(A1:A5,TRUE) But that does not work either. Note -- I am using Excel 2007.

    Read the article

  • Excel - Counting unique values that meet multiple criteria

    - by wotaskd
    I'm trying to use a function to count the number of unique cells in a spreadsheet that, at the same time, meet multiple criteria. Given the following example: A B C QUANT STORE# PRODUCT 1 75012 banana 5 orange 6 56089 orange 3 89247 orange 7 45321 orange 2 apple 4 45321 apple In the example above, I need to know how many unique stores with a valid STORE# have received oranges OR apples. In the case above, the result should be 3 (stores 56089, 89247 and 45321). This is how I started to try solving the problem: =SUM(IF(FREQUENCY(B2:B9,B2:B9)>0,1)) The above formula will yield the number of unique stores with a valid store#, but not just the ones that have received oranges or bananas. How can I add that extra criteria?

    Read the article

1 2 3 4  | Next Page >