Trying to understand hashCode( )

Hello again, I'm trying to understand the hashCode( ) method. I have a textbook which describes it this way:
"A hashcode is a value that uniquely identifies an individual object. For example, you could use the memory address of an object as it's hashcode if you wanted. It's used as a key in the standard java.util.Hashtable[i] class."
Please forgive me if this emplies that I may be a bit slow with this, but this explanation is too vague for me to grasph what's going on here. Can someone thoroughly explain (in a non scientific way), how and why this method is used?
Thanks in advance.

I thought the examples I provided might give you an idea why the hashCode method is useful. I'll try one more brief one, and if that doesn't connect that spare wire to the light bulb over your head, then I'll have to agree with schapel and suggest that you study up on your CS theory.
This will be a really crocked up example, and you could skirt some of the issues with better design, but it's a valid example nonetheless.
You run a greenhouse or an arboretum or something. You've got 25,000 Tree objects (forget their subclasses for now). Trees have properties like species, name (I don't know why you'd name a tree--just bear with me), location, age, medical history. You're going to put your Trees into a java.util.Set, so you've got a collection with one reference to each tree. However, you're getting overlapping subsets of your trees from various sources--that is getAllElms() returns some trees that are also in getAllOlderThan(10). You need to combine all those results into a 1-each collection of Trees.
When you go to add an Object to the Set, the Set has to first check if that Object is already present. The Set implementation could iterate over all its elements and call equals() to see if that Object is already there. Or, it could first get the hashCode (let's say you've implemented hashCode to return the xor of the species and the age). So, maybe 100 out of your 25,000 trees are 50 yeard old Elms. Internally, if the Set implementation keeps a mapping from hashCode to an array of Trees with that hashcode, then it only has to copmare to those 100 trees that match, rather than all 25,000.
As I said, this is a cheezy example. One problem is that if trees are mutable, this Set implementation won't work, since the Set won't know that a Tree's internal values (and hence, possibly, its hashCode) have changed.
Is is making any sense yet?
Okay so please help me understand this rudimentary,
logical reason for wanting to use a hashCode( )? Say
I create a top level class called "Plant.java". Now
from that class I create a subclass called Tree.java
from which several other subclasses and objects are
created. Help me gain a basic understanding of why
and how the hashCode( ) method might be beneficial.
(lol... I feel sort of like I've opened up a cool new
electronic toy, I'm standing here with a "spare wire
in my hand wondering what the heck this part is
for?")
Thanks again for your help. I really apprecitate it.

Similar Messages

  • Hello, World - trying to understand the steps

    Hello, Experts!
    I am pretty new to Flash Development, so I am trying to understand how to implement the following steps using Flash environment
    http://pdfdevjunkie.host.adobe.com/00_helloWorld.shtml         
    Step 1: Create the top level object. Use a "Module" rather than an "Application" and implement the "acrobat.collection.INavigator" interface. The INavigator interface enables the initial hand shake with the Acrobat ActionScript API. Its only member is the set host function, which your application implements. During the initialize cycle, the Acrobat ActionScript API invokes your set host function. Your set host function then initializes itself, can add event listeners, and performs other setup tasks.Your code might look something like this.
    <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" implements="acrobat.collection.INavigator" height="100%" width="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
    Step 2: Create your user interface elements. In this example, I'm using a "DataGrid" which is overkill for a simple list but I'm going to expand on this example in the future. Also notice that I'm using "fileName" in the dataField. The "fileName" is a property of an item in the PDF Portfolio "items" collection. Later when we set the dataProvider of the DataGrid, the grid will fill with the fileNames of the files in the Portfolio.
    <mx:DataGrid id="itemList" initialize="onInitialize()" width="350" rowCount="12"> <mx:columns> <mx:DataGridColumn dataField="fileName" headerText="Name"/> </mx:columns> </mx:DataGrid>
    Step 3: Respond to the "initialize" event during the creation of your interface components. This is important because there is no coordination of the Flash Player's initialization of your UI components and the set host(), so these two important milestone events in your Navigator's startup phase could occur in either order. The gist of a good way to handler this race condition is to have both your INavigator.set host() implementation and your initialize() or creationComplete() handler both funnel into a common function that starts interacting with the collection only after you have a non-null host and an initialized UI. You'll see in the code samples below and in step 4, both events funnel into the "startEverything()" function. I'll duscuss that function in the 5th step.
                   private function onInitialize():void { _listInitialized = true; startEverything(); }

    Hello, Experts!
    I am pretty new to Flash Development, so I am trying to understand how to implement the following steps using Flash environment
    http://pdfdevjunkie.host.adobe.com/00_helloWorld.shtml         
    Step 1: Create the top level object. Use a "Module" rather than an "Application" and implement the "acrobat.collection.INavigator" interface. The INavigator interface enables the initial hand shake with the Acrobat ActionScript API. Its only member is the set host function, which your application implements. During the initialize cycle, the Acrobat ActionScript API invokes your set host function. Your set host function then initializes itself, can add event listeners, and performs other setup tasks.Your code might look something like this.
    <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" implements="acrobat.collection.INavigator" height="100%" width="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
    Step 2: Create your user interface elements. In this example, I'm using a "DataGrid" which is overkill for a simple list but I'm going to expand on this example in the future. Also notice that I'm using "fileName" in the dataField. The "fileName" is a property of an item in the PDF Portfolio "items" collection. Later when we set the dataProvider of the DataGrid, the grid will fill with the fileNames of the files in the Portfolio.
    <mx:DataGrid id="itemList" initialize="onInitialize()" width="350" rowCount="12"> <mx:columns> <mx:DataGridColumn dataField="fileName" headerText="Name"/> </mx:columns> </mx:DataGrid>
    Step 3: Respond to the "initialize" event during the creation of your interface components. This is important because there is no coordination of the Flash Player's initialization of your UI components and the set host(), so these two important milestone events in your Navigator's startup phase could occur in either order. The gist of a good way to handler this race condition is to have both your INavigator.set host() implementation and your initialize() or creationComplete() handler both funnel into a common function that starts interacting with the collection only after you have a non-null host and an initialized UI. You'll see in the code samples below and in step 4, both events funnel into the "startEverything()" function. I'll duscuss that function in the 5th step.
                   private function onInitialize():void { _listInitialized = true; startEverything(); }

  • Trying to understand Android OS updates delays

    This is not another hate mail, it´s more about trying to understand the facts and motives regarding the OS updates (or lack of).
    Hopefully this material will arrive at someone from Sony with enough power to do something about it.
    Ever since I can remember, Sony has been THE brand for electronics. I can´t remember a TV or VCR in my house that it wasn´t Sony, and they lasted for LOTS of years.
    When a couple years ago I finally had the money (and the need) for a Smartphone, i chose the X10 Mini, which is a great little phone from a great brand, but it´s stuck at Android 2.1... which makes it a crippled android nowadays...
    It really bothered me the lack of OS updates, so I chose to buy a Galaxy Nexus, but it´s really expensive in my country. So my second option was a Galaxy Ace 2, but they haven´t arrived to my country yet, so I went with my third option: Xperia Sola, knowing beforehand that it´s a great phone, a great brand, but I might get slow OS updates.
    I bought it about 10 days ago when I saw they were starting to roll out the updates.
    10 days later I still don´t have my update. And not only that, but I don´t see much light at the end of the tunnel...
    I found a thread with the SI numbers that were updated, and there were a bunch on Oct 1, another bunch on Oct 4, and one code on Oct 8, and no other update since...
    I also read that those who did get the update, were having bugs with the OS, and also found threads from other Xperia models, whose updates began rolling 3 months ago, and there is still people who hasn´t gotten the update...
    As a customer, and a owner/CEO of a small company, I have a really hard time understanding how a HUGE company like Sony can be making such mistakes...
    I have been thinking objective reasons, and I can only think of one. I know it´s a wild guess, but I´m starting to think that our salvation might be the very thing that means our condemnation: CYANOGENMOD!!!
    Think about it: Why would Sony spend more money hiring twice as much programmers, when they can make only one update per phone, and sit down and see how CM releases begin to appear, for all tastes and needs. And... IT´s FREE!!!
    Also, if there is a software related problem (way more likely than a hardware problem), then the CM developers take the fall, instead of Sony. And I´m beginning to see custom OS installers that are more user friendly, so it might be something that they take in accout when neglecting OS updates.
    If that´s the line Sony is following, it´s a very risky move and it won´t work. Sony Mobile will crash and burn, but it´s still a better business plan that "let´s get lazy and make ULTRA slow updates so we don´t spend a lot of money programming".
    If you can´t afford more programmers, stop including so much bells and whistles and make your OS near vanilla. Include a couple of Xperia menus, a custom theme and voila!
    The main reason I wanted the Galaxy Nexus is Vanilla OS, which means inmediate OS updates. Sony on the other hand, takes a year or two to release it after its launch. If they release it at all...
    Another though...  why not stop making that many different phones! Really! There are like 5 Xperia models i can´t tell one from the other... even with specs side by side!
    You are trying to make too many phones and you are failing with all of them! (Software and software updates are also part of the phone, one of the most importants...)
    I know hiring programmers is expensive, but you are sacrificing one of the most expensive values for a company EVER: Customer credibility! Which as you know better than me, takes years to create.
    If Apple had problems with carriers and code aprooving and stuff, they might get away with it, becouse they alone have all the devices. If iOS 6 is delayed a few months, it´s delayed for everyone, and besides Apple fanboys rarely complain about Mac products, but Android is a more independent and educated market.
    I´m not saying that Apple users are ignorant, not at all, but I´m pretty sure most iPhone owners don´t even know what processor or how much RAM their phone has. They just "swallow" the Apple Way of Life. (it´s a good phone becouse Apple says so).
    The Android user on the other side, because of the fragmentation of the market, has many brands and models to choose from. An Android user about to buy a new phone will most likely go online looking for different models, specs, reviews in webs and forums...etc.
    You can´t say "I don´t know how HTC and other companies get their updates so soon, but we take a lot more becouse Google and the Operators must aproove the code.", because there are many other brands that have exactly the same difficulties or more, since they are smaller, and we can SEE online that they are indeed delivering solid and relativly fast updates.
    Did we miss something? Does HTC use Witchcraft to get their code aprooved?
    My underlying point is this: You are getting lazy... VERY lazy with software programming for your phones, and WE KNOW IT!
    It´s not the "difficulties" you claim, becouse every brand has those difficulties.
    This isn´t 1999 you know. We are in the information age. If you lie to us and tell us that your phones have the latest OS, I can go online and see that you don´t (Hello!!!). If I see that the company lies to it´s customers, I will stop buying their products. If I´m so dissapointed with how Sony handles OS updates and their customers queries about it, then I want for the first time ever to sell my Cell Phone becouse I´m not happy with it, or the brand behind it.
    We also live in the "Here and now" age. You can´t expect your customers to read about new Android releases on news and blogs, and wait YEARS with arms crossed waiting for their update... The world doesn´t work like that. Not anymore at least...
    It´s not a matter of how many recources you have, it´s about how you use and balance them. GIVE MORE IMPORTANCE TO SOFTWARE UPDATES! IT´S WAY MORE IMPORTANT THAT YOU THINK! LISTEN TO YOUR CUSTOMERS!!!
    You guys are Sony are smart and design great products, but you are not GOD! You are not our wife, no one has sworn alliagence to you.
    If you stop giving us good products and start lying to us, we hate you and stop giving you our money. Simple as that.
    My sola is beatiful, I love the design, the screen, the hardware... but it hasn´t been updated yet to 4.0, not to mention 4.1, which REALLY is the latest version... so stop advertising that your phones have the latest Android OS, unless you want angry customers switching to other companies, which you are getting.
    I also read some stories that Androind 4.0 was announced for the Xperia PLAY, and then it was called off... Do you have any idea how pissed I would be and ripped off I would be if I bought my phone based in that information and then you say it won´t be available?
    Well, actually right now my possition is worse, since you SAY you will update my phone, but you don´t say when, and I read online about people still not getting their updates months after the rollout started, so I´m in the limbo right now...
    As a company, one of the worse things you can do is calling your customers stupid, and when I see the answers you give in this forum, then I feel insulted. I feel like they are talking to an idiot or ignorant person with the so called "diplomatic" answers, which are basicly empty excuses for not doing your job right.
    You gave us the frikking CDs, DVDs and Blu-Rays!!! Don´t tell us you can´t tweak an already built OS in a year!
    I really hope you change their OS update policies really soon, before you lose the already small cellphone market share you have, or at least change your P.R. and C.M. policies towards a more open one.
    We all are humans and make mistakes, but we customers really appreciate honesty and truth.
    Have an open conversation with your customers! Don´t lie about your shortcomings! Accept then and ask the community to help you solve them, ask them what they biggest problems are, what features are most important to them, how often do they expect updates... LISTEN TO THEM!!
    "Succes is a meneace. It tricks smart people into thinking they can´t lose."
    Ps: Nothing personal with the mods from this forum, I´m not killing the messenger, I know that you can ONLY give the info you are allowed to give, and even if you wanted, you probably don´t know the answers yourself, since you work in the Communications department, not Developement or anything technical, and if you can't give any given info, then they probably won´t give it to you either... My message is to the company as a whole. I just hope you will be a good messenger and give this to whoever needs to read it.

    My bad, it´s closer to 40 the number of phones released hehe
    I know it´s all about money, and I know Sony is obligated to neglect users who haven´t given them money after an x ammount of time. However, it´s not a matter of making the phones obsolete earlier, so the users want to buy a new phone faster and therefore getting more money.
    A person will buy a new phone when he/she has the money to do so and wants to do so.
    It´s not a matter of WHEN. It´s a matter of WHAT.
    The question is not "When will that user buy a new phone?", but rather "When that user buys a new phone, whenever that is, what phone will it be?"
    I have a love/hate relationship with Apple. I would never use a iPhone. I would love having any Mac, if someone gives it to me, but I would never spend my harn earned dollars on such an overpriced piece of hardware over general principals.
    However, i do recognice that Steve Jobs was a business genius. Weather you like or love his ideas and methods, he turned a garage project into the biggest company in the world, with a market value higher than Exxon with 1/3 of it´s assets.
    Apple is a money making machine, and that is where the "hate" part of my relationship comes from.
    However, it surprised me a lot to see that they released iOS 6 for the iPhone 3GS, released in 2008!
    That get´s you thinking, that inside all that "SELL NOW" culture Apple is, they also support their older devices that people bought years ago but can't buy a new phone now. However, when they can do it, it will surely be another iPhone. Because they FEEL that the company listens and cares for them.
    Also if you jump from iOS 6 on the 3 GS to a brand new iPhone 5, the transition will be virtually non-existant, except for Siri and a couple of features.
    However jumping from Android 1.5 or 2.1 to Jelly Bean, might not be so easy on some users, making them more likely to give iPhone a shot.
    Since they have to adapt to another phone anyway, they might as well try the apple...
    And for old users, it gives people a sense of continuity and care about the user. Otherwise we feel like being kicked out of a restaurant right after we payed the bill.

  • Trying to understand OIM - Please help

    Hello All,
    I am pretty new to OIM, just trying to understand how OIM works. For the past 4 years I was in Sun IdM and planning to switch over to OIM.
    I read some documentation, I think OIM will perform basic provisioning and it contains out of box connectors to do basic provisoning. I have some questions can anybody please help
    - Sun IdM uses Express language to develop custom workflows or forms, in OIM to develop workflows which language did you use, is it Java or any other language?
    - If I want to provision users on AS/400, HP Open VMS or AIX systems, how can I do that I don't see any out of box connectors for these resources, so in order to integrate these resources do we need to write our own custom connectors?
    - If the out of box connector does not support a specific function on a resource what are the options do we have? for example if the AD connector does not support to delete the exchange mailbox, how your going to perform this in OIM? Do we need to write a Java code for this?
    - How much Java coding is necessary in OIM?
    - Is OIM supports role based provisioning?
    Please share any information.
    Thanks in advance.

    Sun IdM uses Express language to develop custom workflows or forms, in OIM to develop workflows which language did you use, is it Java or any other language?
    - JAVA
    If I want to provision users on AS/400, HP Open VMS or AIX systems, how can I do that I don't see any out of box connectors for these resources, so in order to integrate these resources do we need to write our own custom connectors?
    - If OOTB connectors are not available then you'll have build you own connector as per Target Resource.
    If the out of box connector does not support a specific function on a resource what are the options do we have?
    - You'll have customize their connector as per your requirements or write your own
    How much Java coding is necessary in OIM?
    - We can't calculate how much java. It's totally depends on requirements how much code you'll ahve to write. But everything will be done using Java only.
    - Is OIM supports role based provisioning?
    Here Group represent Role. At a small scale it supports. But for large scale you'll have to use Oracle Role Manager as you do in Sun Role Manager.

  • Trying to understand, being prompted the file compression rules on saving, or not

    Hello,
    I'm trying to understand something, could I ask for your help, please ?
    After working on a jpg file, when I want to save it, still as jpg, with my Photoshop CS5,
    - sometimes photoshop will just save the picture, and it's done
    - sometimes photoshop will show me the compression dialog, "JPEG Options", in which I can choose the compression ratio, the format options (baseline, baseline optimized, progressive), and have an estimation of the total file size
    While not being prompted any dialog is simpler, and I'll then simply assume Photoshop decides to retain the current image's compression and format rules, I must say I like to be in control, and I'd like to know under what form the file is being saved without having to resort to the much more complex "Save For Web" menu.
    Please, would you know WHAT "triggers" the appearance of the JPEG Options when we close/save a jpeg file, in photoshop ? What makes this menu not to appear, what makes it appear ?
    If there are trivial file operations/changes/filters that necessarily trigger its appearance when we want to save, something like that ? I've tried a variety of these, but I still can't figure it out, sometimes it shows in the end, and sometimes it doesn't.
    Thank you very much if you can help me
    Kind regards,
    Oliver

    @ c.pfaffenbichler
    These are images from various sources, not just one.
    I'm deliberately excluding Save For Web, this completely re-processes everything.
    My purpose, precisely, is to know when photoshop takes the decision to retain the image's "rules", and when photoshop decides to pose us the question, how do we want it saved.
    Simply taking a jpeg image, doing stuff on it, and hitting control-w to close the window, and seeing if it will be an
    - «OK, sure, do you want to save ? You clicked OK to confirm you wanted the changes saved ? Good, now it's closed» or a
    - «please sir, how would you like your image saved, tell me the compression ratio and the format options, thank you»

  • UTL_HTTP.end_of_body Exception Error.  Trying to Understand the Reason Why?

    I have the following PLSQL Function that returns a End_of_body Error. This started when we migrated from 10g to 11g. It is simple enough to capture so the error does not stop the Function Flow, but the error causes the OCI driver in OBIEE to error, which prevents the use of OBIEE IBOT to execute. Trying to understand why this error is occurring..not sure if we have a permissions issue on the UTL_HTTP Package or what?
    Anyone seen this problem in 11g? Suggests on resolving would be great. Thanks.
    FUNCTION AA_DEMO_PO_WSDL(IN_MESSAGE IN VARCHAR2)
    RETURN VARCHAR IS
    soap_request varchar2(30000);
    soap_respond varchar2(30000);
    http_req utl_http.req;
    http_resp utl_http.resp;
    launch_url varchar2(240) ;
    o_message varchar2(240) ;
    po_amount number := 2000 ;
    total_calls number := 0;
    cursor c_PO_exists is Cursor Logic..
    begin
    total_calls := 0;
    For po_wsdl in c_PO_exists
    LOOP
    total_calls := total_calls + 1;
    soap_request:='<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header/>
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/PurchaseOrder_Approval">
    <ns1:ProcessRequest><ns1:input>PO' || po_wsdl.order_no || '</ns1:input></ns1:ProcessRequest>
    </soap:Body>
    </soap:Envelope>';
    Begin
    http_req:= utl_http.begin_request('myURL/PurchaseOrder_Approval/1.0','POST','HTTP/1.1');
    utl_http.set_header(http_req, 'Content-Type', 'text/xml') ;
    utl_http.set_header(http_req, 'Content-Length', length(soap_request)) ;
    utl_http.set_header(http_req, 'SOAPAction', 'initiate');
    utl_http.write_text(http_req, soap_request) ;
    http_resp:= utl_http.get_response(http_req) ;
    utl_http.read_text(http_resp, soap_respond) ;
    utl_http.end_response(http_resp) ;
    Exception
    WHEN UTL_HTTP.end_of_body THEN
    utl_http.end_response(http_resp);
    When utl_http.too_many_requests then
    utl_http.end_response(http_resp);
    o_message := 'End_Reponse' || ' from proc.';
    when OTHERS then
    o_message := SQLERRM || ' from proc.';
    return o_message;
    end;
    END LOOP;
    Return 'Workflow Initiated-' ||to_char(total_calls);
    end AA_DEMO_PO_WSDL;

    Hi, thanks,
    it is oracle10g,
    The Exception is : ORA-29266: end-of-body reached
    ORA-06512: at "SYS.UTL_HTTP", line 1349
    then the line in my function ,
    damorgan wrote:
    But I do note that when I do this I always do a get_header_count and get_header before get_read.what get_read , u mean?
    thanks for the link ,
    appreciated

  • I am trying to understand the licensing procedures for using tabKiller for 3.5.7 firefox. Who should I contact for this? I do not see any customer service phone number for Firefox

    I am trying to understand the licensing procedures for using tabKiller for 3.5.7 firefox. Who should I contact for this? I do not have the customer service phone number for Firefox

    Tab Killer is not created by Mozilla, it is created by a private individual who has made it available at no cost for other people to use.

  • [SOLVED] Trying to understand the "size on disk" concept

    Hi all,
    I was trying to understand the difference between "size" and "size on disk".
    A google search gave plenty of results and I thought I got a clear idea about
    it.. All data is stored in small chunks of a fixed size depending on the
    filesystem and the last chunk is going to have some wasted space which
    will *have* to be allocated.. Thus the extra space on disk.
    However I'm still confused.. When I look at my home folder, the size on disk
    is more than 320 GB, where as my partition is actually less than 80 GB, so
    I guess I'm missing something.. Could somebody explain to me what does
    320 GB of 'size on disk' means?
    Thanks a lot in advance..
    Last edited by geo909 (2011-12-15 23:17:25)

    Hi all,
    Thank you for your replies.. My file manager is indeed pcman fm and
    indeed it seems to be an issue.. In b4data's link the last post reads:
    B-Con wrote:
    FWIW, I found the problem. (This bug is still persistent in v0.9.9.)
    My (new) PCManFM bug report is here: http://sourceforge.net/tracker/index.ph … tid=801864
    I submitted a potential patch here: http://sourceforge.net/tracker/?func=de … tid=801866
    Bottom line is that the file's block size and block count data from the file's inode wasn't being interpreted and used properly. The bug is in PCManFM, not any dependent libraries. Details are in the bug report.
    Since PCManFM is highly used by the Arch community, I figured I should post an update here so that there's some record of it in our community. Hopefully this gets addressed by the developer(s) relatively soon. :-)
    I guess that pretty much explains things.. And I think I did understand the 'size on disk' concept
    anyway
    Thanks again!
    Last edited by geo909 (2011-12-15 23:17:10)

  • Trying to understand the sound system

    Here's my problem. My mic didn't work (neither the front mic nor the line-in in the rear), so after some research and trial and error I found that if I do
    modprobe soundcore
    my mic works on both the jacks
    But here's where my confusion lies. This is the output of lsmod |grep snd before probing explicitly for soundcore
    [inxs ~ ]$ lsmod |grep snd
    snd_hda_codec_analog 78696 1
    snd_hda_intel 22122 1
    snd_hda_codec 77927 2 snd_hda_codec_analog,snd_hda_intel
    snd_hwdep 6325 1 snd_hda_codec
    snd_pcm_oss 38818 0
    snd_pcm 73856 3 snd_hda_intel,snd_hda_codec,snd_pcm_oss
    snd_timer 19416 1 snd_pcm
    snd_page_alloc 7121 2 snd_hda_intel,snd_pcm
    snd_mixer_oss 15275 2 snd_pcm_oss
    snd 57786 8 snd_hda_codec_analog,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm_oss,snd_pcm,snd_timer,snd_mixer_oss
    soundcore 6146 2 snd
    [inxs ~ ]$
    So as you can see, soundcore's already loaded, so why do I have to explicitly load it again to get the mic to work?
    Once I add soundcore to my MODULES array and reboot, the lsmod output is also the same as above.
    So my question is -- what does the explicit loading of soundcore do, that is not done by auto-loading of that module?

    Oh... since your topic is Trying to understand the sound system, that puts you (and me) inside the whole world's population... chuckle. But I thought I'd pass along a document written by probably "The" main ALSA developer that I totally stumbled across just 3 days ago.
    Go here:
    http://kernel.org/pub/linux/kernel/people/tiwai/docs/
    and download the flavor of your choice of the "HD-Audio" document, or simply view it online. It documents the deepest dive into the current ALSA snd_hda_* layers and issues that I've found to date (but still leaves me wanting).
    Why that document isn't plastered across the interwebs is beyond me. I only get 11 hits when I search for it... such are the secrets of the ALSA world I guess.
    Last edited by pigiron (2011-08-26 18:26:48)

  • Trying to understand the MODEL clause

    Hi All,
    I'm finally biting the bullet and learning how to use the model clause, but I'm having a bit of trouble.
    The following example data comes from a book "Advanced CQL Functions in Oracle 10g".
    with sales1 as (select 'blueberries' product
                          ,'pensacola' location
                          ,9000 amount
                          ,2001 year
                      from dual
                    union all
                    select 'cotton', 'pensacola',16000,2001 from dual
                    union all
                    select 'lumber','pensacola',3500,2001 from dual
                    union all
                    select 'cotton','mobile',24000,2001 from dual
                    union all
                    select 'lumber', 'mobile',2800,2001 from dual
                    union all
                    select 'plastic','mobile',32000,2001 from dual
                    union all
                    select 'blueberries','pensacola',9000,2002 from dual
                    union all
                    select 'cotton', 'pensacola',16000,2002 from dual
                    union all
                    select 'lumber','pensacola',3500,2002 from dual
                    union all
                    select 'cotton','mobile',24000,2002 from dual
                    union all
                    select 'lumber', 'mobile',2800,2002 from dual
                    union all
                    select 'plastic','mobile',32000,2002 from dual
                    union all
                    select 'blueberries','pensacola',9000,2003 from dual
                    union all
                    select 'cotton', 'pensacola',16000,2003 from dual
                    union all
                    select 'lumber','pensacola',3500,2003 from dual
                    union all
                    select 'cotton','mobile',24000,2003 from dual
                    union all
                    select 'lumber', 'mobile',2800,2003 from dual
                    union all
                    select 'plastic','mobile',32000,2003 from dual
    select location, product, year, s
    from sales1
    model
    --return updated rows
    partition by (product)
    dimension by (location,year)
    measures (amount s) ignore nav
    (s['pensacola',2003] = sum(s)['pensacola',cv() > cv()-1])I would have expected the measures clause to return the sum of all amounts for pensacola where the year > 2003 - 1 = 2002. which would make the total for [blueberries,2003] = 1800, but instead it comes out as 27000, apparently summing all values for blueberries for that partition.... equivalent to sum(s)['pensacola',ANY].
    how would I go about making s['pensacola',2003] = the sum of itself plus the previous row?
    I realise I can do
    s['pensacola',cv()]+s['pensacola',cv()-1]but I'm really trying to understand why what I have doesn't appear to work the way I expect.

    Because
    (s['pensacola',2003] = sum(s)['pensacola',cv() > cv()-1])
    means
    (s['pensacola',2003] = sum(s)['pensacola',cv(year) > cv(year)-1])
    means
    (s['pensacola',2003] = sum(s)['pensacola',2003 > 2003-1])
    means
    (s['pensacola',2003] = sum(s)['pensacola',2003 > 2002])
    means
    (s['pensacola',2003] = sum(s)['pensacola',year is any])
    s['pensacola',cv()]+s['pensacola',cv()-1]
    means
    sum(s)['pensacola',year between cv()-1 and cv()]

  • Trying to Understand the PostSyncCleanup parameter

    I've got a problem with running my application on the Australian version of Windows. We have a "test" application built around SQL Server Compact Merge Replication Library (thanks ErikEJ) and that works but our application doesn't.
    One of the main differences with our application code is that we do not set the PostSyncCleanup value to anything and the library sets it to 2 per this link:
    http blogs.msdn.com/b/sqlblog/archive/2009/04/15/sql-compact-performance-postsynccleanup-to-turn-off-updatestatistics-during-initial-download-of-sql-compact-replication.aspx (put the :// back to get the link)
     I'm trying to understand the impact of making that our "production" configuration since we haven't been using it.  The description looks harmless enough but I don't really understand what statistics I'm turning off and what the impact
    would be and what even the default setting is.  Anything that could enlighten me would be appreciated along with a guess as to why that might be causing a problem on the Australian version of Windows would be appreciated.

    So we've been running with the default value (0) and have not really had any "problems".  I haven't done any testing but I'm ok with faster, like everyone would be, but am also a bit risk averse so want to know what exactly I'm turning off.
    I also saw this advice from Rob Tiffany:
    Use the appropriate x64, x86 or ARM version of SQL Server Compact 3.5 SP2 to take advantage of the
    PostSyncCleanup property of the SqlCeReplication object that can reduce the time it takes to perform an initial synchronization. Set the
    PostSyncCleanup property equal to 3 where neither
    UpdateStats nor CleanByRetention are performed.
    Here: http  robtiffany.com/microsoft-sql-server-compact-3-5-sp2-has-arrived/
    So, is the best advice to use that parameter and set the value to 3 or 2
    I don't really know what I'm losing to "not performing" UpdateStats or CleanByRetention and does making that change need I need to do something else on the server or client to "clear out" or "clean up" something that this is
    doing.

  • Trying to understand the code???

    Hi,
    I am trying to understand the following bit of code, currently the code puts each catalogue into a different row of the table but i want each catalogue to be put in the next column
    (so the catalogues appear across the page on the actual web page). The following code is for the page in question but im not sure how much is relevant so i will paste it all and highlight the section i think is relevant:
    <html>
    <%-- DECLARATIONS --%>
    <%@ page import="se.ibs.ns.cf.*,  se.ibs.ccf.*, se.ibs.bap.*, se.ibs.bap.util.*, se.ibs.bap.web.*,  java.util.*, se.ibs.ns.icat.*, se.ibs.bap.asw.cf.*, java.lang.*" %>
    <% ItemCatalogueBean bean = (ItemCatalogueBean)SessionHelper.getSessionObject("ItemCatalogueBean",session);
       String resourcePath = bean.getResourcePath(null);
       String title = "Product catalogue";
       String languageCode = bean.getLanguageCode();
    %>
    <%@ include file="FuncHead.jsp" %>
    <BODY class="IBSBody" onLoad="loaded = true;">
    <form method="POST" action=<%= bean.getEncodedServlet("se.ibs.ns.icat.ItemCatalogueSearchServlet", response) %> name="basicForm">
    <%@ include file="FuncSubmitScript.jsp" %>
    <%@ include file="FuncPageBegin.jsp" %>
    <div align="center">
      <table border="0" width="895">
        <tr>
          <td align="left" width="502">
    <div align="left">
      <table border="0" width="500">
        <tr>
          <td class="IBSPageTitleText" align="left" valign="top" width="238">
              <%@ include file="FuncPageTitle.jsp" %>
              <%@ include file="FuncPageTitleImage.jsp" %>
                    <br>
           On this page you can see the product catalogues. Click on one of the
           links to go to the next level. Alternatively you can click the <b>Search
           catalogue</b> button to find the products of interest.</td>
               <td width="248" valign="bottom">
                <div align="left"><%@ include file="FuncShoppingCart.jsp" %></div>
               </td>
        </tr>
      </table>
    </div></td></tr></table></div>
    <input type="submit" value="Search catalogue" name="ACTION_NONE" onClick="submitButtonOnce(this); return false">
    <hr>
    <%-- REPEAT CATALOGUES --%>
    <div align="left">
    <table border="0" width="100%">
    <% Vector catalogues = bean.getItemCatalogues();
            int cataloguesSize = catalogues.size();
               for (int i = 0; i < cataloguesSize; i++){
                      BAPItemCatalogue cat =  (BAPItemCatalogue) catalogues.elementAt(i); %>
              <%-- LINK AND MARK AS NEW --%>
                  <tr>
                         <td width="23%"><a class="IBSMenuLink" href="link" onClick="javascript:invokeLink('<%= bean.getEncodedServlet("se.ibs.ns.icat.ItemCatalogueCategoryServlet", response) %>?CODE=<%= ToolBox.encodeURLParameter(cat.getCode())%>'); return false">
                              <%= cat.getDescription(languageCode) %></a>
                         </td>
                         <td width="40%" align="right">
                              <% if (cat.isNew()) {%>
                                     <img border=0 src="<%= resourcePath %>new.gif">
                              <% } %>
                        </td>
                  </tr>
              <%--  CATALOGUES IMAGE AND INTERNET INFORMATION (text, multimedia objects,downloads, links...) --%>
                  <tr>
                         <td width="23%" valign="top" align="left">
                              <% if (bean.isAdvanced(cat) && bean.hasMultimediaImage(cat)) { %>
                                   <a href="link" onClick="javascript:invokeLink('<%= bean.getEncodedServlet("se.ibs.ns.icat.ItemCatalogueCategoryServlet", response) %>?CODE=<%= ToolBox.encodeURLParameter(cat.getCode())%>'); return false">
                                   <img border="0" src="<%= bean.getMultimediaImage(cat) %>"></a>
                        <% } else {%>     
                                   <img border="0" src="<%= resourcePath %>Catalog.gif">
                              <% } %>
                         </td>
                         <td class="IBSTextNormal" width="40%" valign="top">
                              <%= bean.getWebText(cat) %>
                         </td>
                  </tr>
                  <tr>
                         <td width="23%">
                         </td>
                         <td width="40%">
                         <% Vector mmLinks = bean.getMultimediaLinks(cat);
                      int mmLinksSize = mmLinks.size();     
                              for (int ml=0; ml<mmLinksSize; ml++){
                                   BAPCodeAndDescription mmLink = (BAPCodeAndDescription)mmLinks.elementAt(ml); %>
                                   <a class="IBSLink" href="<%= mmLink.getCode() %>" target="_blank"><%= mmLink.getDescription() %></a><br>
                         <% } %>
                   <% Vector webLinks = bean.getWebLinks(cat);
                        int webLinksSize = webLinks.size();
                        for (int wl=0; wl<webLinksSize; wl++){
                                   BAPCodeAndDescription webLink = (BAPCodeAndDescription)webLinks.elementAt(wl); %>
                                   <a class="IBSLink" href="<%= webLink.getCode() %>" target="_blank"><%= webLink.getDescription() %></a><br>
                        <% } %>
                         </td>
                  </tr>
                <%}%>
    </table>
    </div>
    <%@ include file="FuncPageLinks.jsp" %>
    <%@ include file="FuncPageEnd.jsp" %>
    </form>
    </body>
    </html>i hope someone could help me to understand this,
    thank you for your help

    You've probably already seen these, but here are a couple of links that may help.
    http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/operators.html#array_a ccess
    http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/Array.html
    What's basically happening is that the "for" loop goes through each item in the array.  Don't be confused by the fact that two of the items in the array are Strings and one is an Integer - variable i being a String has nothing to do with the data type of the elements in the array.
    The following code:
    private function createLabels():void
         var myArray:Array = ['one', 'two', 3];
         for(var i:String in myArray)
              trace("i = " + i);
              trace(myArray[i]);
    gives the following results:
    i = 0
    one
    i = 1
    two
    i = 2
    3
    From that we can see that the "for" loop is assigning the index number of each array element, not the actual array element ('one', 'two', or 3) to the variable i.  So calling myArray[i] is the same as calling myArray[0] the first time through the loop.  This type of "for" loop is just a shorter way of doing the following, which produces exactly the same results:
    private function createLabels():void
         var myArray:Array = ['one', 'two', 3];
         for(var i:int = 0; n < myArray.length; i++)
              trace("i = " + i);
              trace(myArray[i]);
    Hope that helps.
    Cheers!

  • Trying to understand the basic concept of object oriented programming.

    I am trying to understand the basic concept of object oriented programming.
    Object - a region of storage that define is defined by both state/behavior.
    ( An object is the actual thing that behavior affects.)
    State - Represented by a set of variables and the values they contain.
    (Is the location or movement or action that is the goal that the behavior is trying to accomplish.)
    Variables- (What does this mean?)
    Value - (What does this mean?)
    Behavior - Represented by a set of methods and the logic they implement.
    ( A set of methods that is built up to tell's the how object to change it's state. )
    Methods - A procedure that is executed when an object receives a message.
    ( A very basic comand.For example the method tells the object to move up, another method tells the method to go left. Thus making the object move up/left that combination is the behavior.)
    Class - A template from which the objects are created.
    ( I am very confused on what classes are.)
    - The definitions of the words I obtained from the "Osborne Teach Yourself Java". The () statements are how I interperate the Mechanisms (I do not know if Thats what you call them.) interact with each other. I understand my interpretation may be horribly wrong. I will incredibly appreciate all the support I may get from you.
    Thank you

    Object oriented programming is a replacement for the older idea of procedural programming (you can research procedural programming in google). As I understand it, in procedural programming, you have a step by step set of function calls to accomplish some task. Each function receives a data structure, manipulates it, and passes it to the next function. The problem with this is that each function preforms some action for the overall task and can't easily be reused by some other task. Its also harder to read the flow of what is happening with raw data structures flying all over the place.
    In object oriented programming, an object calls a function of another object and receives back, not a data structure, but another object. Objects contain a data structure that can only be accessed by its functions. An object is not so much a sub component of a bigger task, as it is a service that any other task can use for any purpose. Also, when you pass an object to the caller, the caller can ask questions about the data structure via its functions. The developer doesnt have to know what the previous function did to the data by reading up on any documentation, or having to reverse engineer the code.
    I suggest the best way of learning this is to code something like a library object.
    A library object contains a collection of book objects
    A book object contains a collection of chapter objects
    A chapter object contains a collection of paragraph objects
    A paragraph object contains a collection of sentence objects
    A sentence object contains a collection of word objects.
    Add functions to each object to provide a service
    Example: A library object should have a:
    public void addBook(Book book)
    public Book getBook(String title)
    public boolean isBookInLibrary(String title)
    The key is to add functions to provide a service to anyone who uses your object(s)
    For example, what functions (service) should a paragraph object provide?
    It shouldn't provide a function that tells how many words there are in a sentence. That function belongs to a sentence object.
    Lets say you want to add a new chapter to a book. The task is easy to read
    if you write your objects well:
    Sentence sentence1=new Sentence("It was a dark and stormy night");
    Sentence sentence2=new Sentence("Suddenly, a shot ran out");
    Paragraph paragraph=new Paragraph();
    paragraph.addSentence(sentence1);
    paragraph.addSentence(sentence2);
    Paragraphs paragraphs=new Paragraphs();
    paragraphs.addParagraph(paragraph);
    Library library= new Library();
    library.getBook("My Novel").addChapter("Chapter 1",paragraphs).
    Now, lets say you want to have a word count for the entire book.
    The book should ask each chapter how many words it contains.
    Each chapter should ask its paragraphs, each paragraph should ask
    its sentences. The total of words should ripple up and be tallied at each
    stage until it reaches the book. The book can then report the total.
    Only the sentence object actually counts words. The other objects just tallies the counts.
    Now, where would you assign a librarian? What object(s) and functions would you provide?
    If written well, the project is easily extensible.

  • Trying to understand the Serialization interface

    Im trying to understand the Serialization of objects?
    As an example, I create a Library class that implements Serializable, that stores a collection of Book objects
    If I am only looking at saving a Library object to file, does the Book class require Serialization also or just the Library?
    I have read the API on serialization, no answer there, if it is it's not easy to understand or read into the API...

    There are some really important things to know about when doing serialization. For example one important thing to know about that not is mentioned here is that your serializable classes must define its own private static final long serialVersionUID because if you not do that will you not be able to deserialize (read in) the data you have saved later if you change anything in your serializable class. It is a bit tricky to manage files to which you have serialized different versions of your class, that is versions where you have added more serializable members to the class after you have serialized files. Well, it is not a problem if you don´t care if you have to type in all your saved data again every time you change anything instead of deserialize it (read it) from your file of course :)
    Situations like this may be handled if you define your own (private) writeObject(ObjectOutputStream) and your own readObject(ObjectInputStream) methods in your serializable class but there is a better a lot smarter way to handle this. Use of a serialization proxy! how to use that is described in the excellent book Effective Java 2nd ed. With a serialzation proxy for every serializable version of your class (where a version corresponds to a version of your class with differences in its number of serializable members) may your class deserialize data written from elder versions of your class also. Actually is it first since I read the last chapter of Effective Java that I think I have myself begin to understand serialization well enough and I recommend you to do the same to learn how to use serialization in practice.

  • Trying to understand and learn how to use btrfs

    I have been the past days trying to get my head around how btrfs works
    I have been trying tools like mkinitcpio-btrfs (very poorly documented) and now, if i list the subvolumes i have in certain volume (/) i see i have 4 subvolumes that have been created while playing around.
    If i try to delete them with "sudo btrfs subvolume delete __active", for example, I get a "ERROR: Error accessing '__active'
    What am I doing wrong?
    Also, I cannot get the whole idea about the difference between snapshots and subvolumes, i mean, a snapshot should be a directory that saves the changes made on the fs, s, if you want to roll back those changes, you just have to make btrfs "forget" the changes stored in that directory and move along, but I cannot take the idea of the subvolume thing.....
    As btrfs is quite experimental and the wikis are not noob-proof still, I'd appreciate if someone gave me a hand trying to understand these concept...
    For the moment, I'm just using it on a test computer and on a personal laptop with no fear of data loss,.
    Any help is welcome
    Thanks!
    Last edited by jasonwryan (2013-07-19 23:13:27)

    I honestly think it is probably a better idea to not use mkinitpcio-btrfs.  As mentioned above, it is poorly documented, and for me it has never worked right (if at all).  It is an unofficial AUR package, and unfortunately our wiki still seems to give the false impression that using this package is the way to user btrfs with Arch.
    The way I have my system set up is that in subvolid=0 (the root of the btrfs filesystem) I have a rootfs subvolume and a home subvolume (there are others, but these are what primarily make up my system).  So in my fstab, I basically have two nearly identical lines, but one has no subvol specified and is mounted at /, and the other has 'subvol=home' mounted at /home. 
    So in order to make it so that I can change the root filesystem as I please, instead of having the / fstab entry specify the subvolume, I put it in the kernel command line.  That is, I have 'rootflags=subvol=rootfs' in the kernel command line.  So if I want to change it, I simply change the path to one of the snapshots. 
    Just remember that if you are one who likes a custom kernel, it is likely that you will have to have an initamfs no matter what you compile into your kernel.  For one thing, the kernel has no mechanism for scanning for multiple device btrfs filesystems.  But also, I have read that the kernel itself cannot handle the rootflags kernel command line argument.
    Oracle Linux does something interesting with their default setup.  They are not a rolling release, so this probably wouldn't work so well in Arch Linux, but they actually install the root filesystem (I think it is actually done to subvolid=0) and then after installation of the packages, a snapshot of the root filesystem is made, and the system is setup to boot off of that snapshot.  So it is almost like having an overlayfs on openwrt.  There is always a copy of the original system, and and changes that are being made are being done "on top" of the original.  So in the event of an emergency, yo can always get back to the original working state.
    If you put your root filesystem on something other than the root of the btrfs filesystem (which you should, as it makes the whole setup much more flexible), then you should also set up a mountpoint somewhere to give administrator access to the filesystem from subvolid=0.  For example, I have an autofs mountpoint at /var/lib/btrfs-root.   chose that spot because /var/lib is where devtools puts the clean chroot.  So it seemed as reasonable a place as any.
    You should go to the btrfs wiki, and peruse through the stuff there... not our wiki, but the actual btrfs one, as our wiki is pretty sparse.  There is not all that much content there (not like the Arch wiki), but it does cover the features pretty well.  I mean, there is certainly quite a lot for being information on only a single filesystem, but it shouldn't take you too long to get through it.  There are a few links to articles about midway down the front page.  What really gave me a better grasp of getting started with btrfs were the ones titled "How I Got Started with the Btrfs Filesystem for Oracle Linux" and "How I Use the Advanced Capabilities of Btrfs".

Maybe you are looking for