Map long to long.

Hi all,
I trying to crosstrain myself from C# to java and i got stuck here. For a certain algorithm i need to store answers from previous calls to speed things up. So for instance the answer to 10 is 50. (it's not really that simple but for the question it should work.) So i want to store previous calls and see if i can look them up (or a similar case)
So i tried HashMap<long, long> divisors = new HashMap<long, long>();
and all kinds of variations but it keeps telling me that it found a long where it expect a reference.
What collection can i use to map long to long? In C# i could just use SortedList<long, long>.
Any ideas?
Regards,
Gert-Jan

In Java, long is a primitive type. Generics (that's the <> stuff) cannot be used with primitives. So you either have to use a Map<Long, Long> or maybe have a look at http://trove4j.sourceforge.net/
And please make sure you understand the difference between C#'s templates and Java Generics :)

Similar Messages

  • Mapping CLOB and Long in xml schema

    Hi,
    I am creating an xml schema to map some user defined database objects. For example, for a column which is defined as VARCHAR2 in the database, I have the following xsd type mapping.
    <xsd:element name="Currency" type="xsd:string" />
    If the oracle column is CLOB or Long(Oracle datatype), could you please tell me how I can map it in the xml schema? I do not want to use Oracle SQL type like:
    xdb:SQLType="CLOB" since I need a generic type mapping to CLOB. Would xsd:string still hold good for CLOB as well as Long(Oracle datatype) ?
    Please help.
    Thanks,
    Vadi.

    The problem is that LONGs are not buffered but are read from the wire in the order defined. The problem is the same as
    rs = stmt.executeQuery("select myLong, myNumber from tab");
    while (rs.next()) {
    int n = rs.getInt(2);
    String s = rs.getString(1);
    The above will fail for the same reason. When the statement is executed the LONG is not read immediately. It is buffered in the server waiting to be read. When getInt is called the driver reads the bytes of the LONG and throws them away so that it can get to the NUMBER and read it. Then when getString is called the LONG value is gone so you get an exception.
    Similar problem here. When the query is executed the CLOB and BLOB locators are read from the wire, but the LONG is buffered in the server waiting to be read. When Clob.getString is called, it has to talk to the server to get the value of the CLOB, so it reads the LONG bytes from the wire and throws them away. That clears the connection so that it can ask the server for the CLOB bytes. When the code reads the LONG value, those bytes are gone so you get an exception.
    This is a long standing restriction on using LONG and LONG RAW values and is a result of the network protocol. It is one of the reasons that Oracle deprecates LONGs and recommends using BLOBs and CLOBs instead.
    Douglas

  • Signature: FSUpdateOperationStatus(void const*, TCountedPtr TCFURLInfo const&, long long, long long, long long, long long, unsigned long). No support Docs on file for this problem. Multiple crashes on opening Firefax. Running OSX 10.6.4.

    Signature:
    FSUpdateOperationStatus(void const*, TCountedPtr<TCFURLInfo> const&, long long, long long, long long, long long, unsigned long)
    No Support Docs on File.
    Firefox crashes every time it is opened.
    UUID 38fc1438-492f-4ce3-91d4-5ef922101027
    Time 2010-10-27 11:19:32.620395
    Uptime 11
    Last Crash 110 seconds before submission
    Install Age 610295 seconds (1.0 weeks) since version was first installed.
    Product Firefox
    Version 3.6.11
    Build ID 20101012104758
    Branch 1.9.2
    OS Mac OS X
    OS Version 10.6.4 10F569
    CPU x86
    CPU Info GenuineIntel family 6 model 15 stepping 11
    Crash Reason EXC_BAD_ACCESS / KERN_PROTECTION_FAILURE
    Crash Address 0x8
    User Comments
    Processor Notes
    EMCheckCompatibility Fal

    Looking at the crash log it looks like AE might be crashing in:
    net.telestream.wmv.export 
    Can you try uinstalling Flip4Mac (or whatever you have installed from http://www.telestream.net/telestream-products/desktop-products.htm)? You may need to manually go deep into /System to remove them.
    --c

  • Word File Takes Longer and Longer to Save

    I’ve been working daily on the same 100-page document for several months. I had no problems with the document under Word 2003. However, under Word 2010 the file grows in size over time, and saving the file takes longer and longer to the point where there
    are significant timeouts (Word is “not responding”) whenever an automatic save occurs. 
    I don't want to diable automatic saves because Word does crash for me on rare occasions, generally if I do something "too fast".
    I’ve found a workaround for the problem, and every three weeks or so after the automatic saves have become painfully long I copy the document to the clipboard (except for the last paragraph mark) and then I open a new document based on the relevant template
    and I paste the clipboard contents into the new document. I rename the old version of the document and the new version becomes the working version. This reduces the file size (currently around 1.4 MB) by about 150 KB and the problem goes away for another three
    weeks.
    Certain aspects of my situation are unusual, and these may or may not be relevant to the problem:
    At the end of each day I use (via a macro) the Review, Compare feature of Word to compare the document with the previous day’s version to allow me to reread any changes I made to it.
    I use various other macros for intelligent page-turning, resizing windows, smart Find, etc.
    I maintain the document as a DOC file (Word 97-2003 Compatibility Mode) because I need to share the document with an organization that requires this format.
    The document flips back and forth a few times between being a one-column and two-column document.
    The document has a table of contents on the last page.
    The headings in the document have embedded section and subsection numbers.
    The document has numerous embedded SEQ and cross-reference fields.
    The document has embedded EMF pictures that were generated by a non-Microsoft application.
    The long times to save the file and the temporary solution I’ve found to the problem suggest that some "junk" is accumulating “in” the last paragraph mark. This junk doesn't cause any operational errors, but it slows things down to the point where
    the auto-save times out and I temporarily get the distracting "not responding" message. It would be nice if Word could automatically eliminate the junk in the last paragraph mark so that I wouldn’t have to do it manually.
    Do you have any suggestions for how I might eliminate the problem?
    I'd be pleased to send a copy of the slow-saving file to a Microsoft Word programmer for diagnosis of the problem.
    I have up-to-date Windows 7 professional (64 bit) and Word 2010 14.0.6129.5000 (32 bit).
    Thanks for your help,
    Don Macnaughton

    I am experiencing exactly the same save issue, although I cannot use the suggestion of copying to a new document as I have allot of references within the same document and I'm scared that I'll loose them (or mess them up).
    It is nearly a year later, did you have any luck?
    Francois,
    I'm still experiencing the problem. However, I've now converted the document from a DOC to a DOCX, but that made no difference.  So every 18 or so days I copy all of the document into a new document except for the last paragraph mark
    and the problem goes away for another 18 or so days.  For my document this solution is fully reliable although it's less convenient because it's a little complicated and I worry I may make a mistake or some text may be lost in the transition.
    So I'm still looking for a solution to the problem. Is there anything unique about your document or your handling of the document that might be the cause of the problem?  Are you using macros, Compare Versions, switching back and forth between
    one and two columns, or anything else that is common to the features that I list in my first post in this thread?
    You might want to try my copying solution as a test while keeping your original document as the official version that you continue to work with.  You could then check the test document very carefully to see if my solution works with your
    document.  You might find that you can trust my solution (or you might not). 
    By the way, I make sure that the copy worked properly by doing a Compare Versions of the old and new documents.  (Surprisingly, sometimes the compare finds very minor differences between the two documents, but usually not.)
    If the problem really bothers you, you can hire Microsoft Support, although that will cost you some money.  If you do that, please let us know the outcome.
    Don Macnaughton

  • Migration of LONG and LONG RAW datatype

    Just upgraded a DB from 8.1.7.4 to 10.2.0.1.0. In the post-upgrade tasks, it speaks of migrating tables with LONG and LONG RAW datatypes to CLOB's or BLOB's. All of my tables in the DB with LONG or LONG RAW datatypes are in the sys, sysman, mdsys or system schemas (as per query of dba_tab_columns). Are these to be converted? Or, does Oracle want us to convert user data only (user_tab_columns)?

    USER_TAB_COLUMNS tells you the columns in the tables owned by the current user. There may well be many users on your system that you created that contain objects. I suppose you could log in to each of those schemas and query their USER_TAB_COLUMNS table, but it's probably easier to query DBA_TAB_COLUMNS with an appropriate WHERE clause on the owner of the objects.
    Justin

  • Error:Type mismatch: cannot convert from Long to Long

    hi friends,
    I've a problem.I've a JSP that does some long converions,and its working fine when i make it run on my machine i.e
    (Running Tomcat5.0),but when I deploy this file on the server which runs Tomcat 5.5.7,it throws this error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 20 in the jsp file: /abc.jsp
    Generated servlet error:
    Type mismatch: cannot convert from Long to Long
    Can anyone of you,tell me where i am going wrong???

    Here is an example of doing it with a JavaBean... the bean looks like this:
    package net.thelukes.steven;
    import java.io.Serializable;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class FormHandlerBean implements Serializable {
         private static final long serialVersionUID = 1L;
         private Date startTime = null;
         private DateFormat dateFormatter;
         public FormHandlerBean() {
              setDateFormat("yyyy-MM-dd hh:mm:ss");
         public void setStart(String strt) {
              setStartAsString(strt);
         private void setStartAsString(String strt) {
              setStartAsDate(getDate(strt));
         private void setStartAsDate(Date d) {
              startTime = d;
         private Date getDate(String s) {
              Date d = null;
                   try {
                        d = dateFormatter.parse(s);
                   } catch (ParseException pe) {
                        System.err.print("Error Parsing Date for "+s);
                        System.err.println(".  Using default date (right now)");
                        pe.printStackTrace(System.err);
                        d = new Date();
              return d;
         public long getStartAsLong() {
              return getStart().getTime();
         public String getStartAsString() {
              return Long.toString(getStartAsLong());
         public Date getStart() {
              return startTime;
         public void setDateFormat(String format) {
              dateFormatter = new SimpleDateFormat(format);
    }You would only need to make the getStartXXX methods public that need to be accessed from the JSP. For example, if you will not need to get the Long value of the time, then you do not need to make getStartAsLong public...
    The JSP looks like this:
    <html>
      <head>
        <title>I got the Form</title>
      </head>
      <body>
        <h3>The Output</h3>
        <jsp:useBean class="net.thelukes.steven.FormHandlerBean" id="formHandler"/>
        <%
             formHandler.setStart(request.getParameter("start"));
        %>
        <table>
          <tr><td>Start as String</td><td><jsp:getProperty name="formHandler" property="startAsString"/></td></tr>
          <tr><td>Start as Date</td><td><jsp:getProperty name="formHandler" property="start"/></td></tr>
          <tr><td>Start as long</td><td><jsp:getProperty name="formHandler" property="startAsLong"/></td></tr>
        </table>
      </body>
    </html>If this were a servlet processing the form rather than a JSP, I might throw the ParseException that might occur in getDate and catch it in the Servlet, with which I could then forward back to the form telling the user they entered mis-formatted text value... But since JSPs should be mainly display, I catch the exception internally in the Bean and assign a safe value...

  • Long.toString(long, int) throws ArrayIndexOutOfBoundsException

    We're using Long.toString(long, int) to convert a long into a base-32 string, which is used as a primary key for entities in our database. On occasion, Long.toString(long, int) throws an ArrayOutOfBoundsException! This only occurs in the deployed system, I cannot get it to occur in a testing environment.
    The object that contains the call to Long.toString(int, long) is shared by multiple threads, but the state of the object is immutable and access to the object is not synchronized. I have tested this code extensively with multithreaded access and cannot reproduce the exception in a test environment.
    Furthermore, this bug only occurs on Linux.
    As a workaround, we have a loop that will attempt the call 5 times, and then fail if the call could not be completed. Generally, this helps to get the code running but will sometimes fail.
    Here are some characteristics of the problem:
    1) Linux kernel 2.4.10 on Pentium III.
    2) Sun JVM 1.3.1_01
    3) Code is accessed from a session bean deployed into JBoss 2.4.3.
    4) Database entities have undergone bytecode enhancement per JDO specification.
    Obviously, the bytecode enhancement is most suspect here. The class that contains the error-prone code is not enhanced, but entities do contain references to instances of the primary key class.
    At first blush this sounds like a classic memory corruption issue that is surfacing in Long.toString() but is probably caused elsewhere. Has anybody seen anything like this or know of either a solution or suggested debugging procedure?
    Thanks.
    -brian

    We already discussed that approach. The reason that
    it was rejected is because my C experience suggests
    that it will just move the corruption evidence to another
    area of the application with possibly more insidious
    effects.I'm not so sure about that. Does your five-try loop actually help? If a stateless method throws an IndexOutOfBoundsException with a given set of parameters, then I would expect it to always throw this exception with the same parameters. Any other behaviour is non-deterministic and not suitable (IMHO) for a production machine.
    I assume you are manipulating arrays in other locations of your code... if these other locations aren't displaying similar non-deterministic behaviour, then common sense dictates that writing your own toString method will not exhibit the same non-deterministic behaviour.
    A little test, compile a class (TestLong, for argument sake) with the method exactly from the Sun source. Decompile it to byte-code with 'javap -c TestLong', and compare that to the same method from Long with 'javap -c java.lang.Long'. If the bytecode isn't identical (Barring numbering differences for class reference table differences), then the implementation you have is not the expected.
    A final suggestion, try a different JVM - both IBM and Sun provide JVMs for linux?

  • Casting long- double- long

    HI all,
    To me casting has always meant changing the type of pointer that points to the data, but leaving the bits intact. However when I try the following:
         long bob = 7829675779835553223l;
         double bob_double = (double) bob;
         long bob_double_long = (long) bob_double;
         System.out.println("bob " + bob);
         System.out.println("bob_double " + bob_double);
         System.out.println("bob_double_long " + bob_double_long);
         System.out.println("bob == bob_double_long " +
                   (bob == bob_double_long));
    The result is not the same. The last three bits seem to change. My guess is that casting calls Math.round() instead of just reinterpreting the bits...
    1. Is this true?
    2. Can I avoid it?
    Thanks!

    An odd alternative I thought of if you want to go crazy...
    I don't believe the JVM spec requires that byte codes actually push and pull the same type. I believe it does verify sizes though. But since double and long are the same size, it should be possible to create a class that pushes double to the stack and then pops a long. And the reverse.
    Using javap to look at the output it should be fairly easy to figure it out even without a great deal of understanding of byte codes. And then a byte code compiler could be used. Or even hand editing using a hex editor.

  • Why do contacts name keep getting longer and longer?

    On some of my contacts, the name keeps getting longer and longer.
    For example, if my name is Jason Kahng.
    After a few weeks, when I lookup my name in Contacts it comes up as "Jason Kahng Jason Kahng Jason Kahng"
    This is very annoying. If I edit the name back down to Jason Kahng, it will do this again a few weeks later.
    Please let me know how to fix this problem.
    Thank you!

    Your iPhone uses Wi Fi to sync your contacts, not iTunes with iOS 5.0.1
    Tap Settings > iCloud
    Switch Contacts off then back on then reset the iPhone.
    Hold the On/Off Sleep/Wake button and the Home button down at the same time for at least ten seconds, until the Apple logo appears.

  • How can I reset my sons restrictions pass code? I have failed 9 attempts and it locks me out longer and longer.thx

    How can I reset my sons restrictions pass code? I have failed 9 attempts and it locks me out longer and longer.thx

    see here
    http://support.apple.com/kb/HT1212
    No choice

  • 3.x Workbooks taking longer and longer to run each week

    Hey all,  I have a user who has embedded 5 versions of the same query into a workbook.  He runs this workbook every monday.  When he first created the workbook it took 30 minutes to run.  Each week that goes by the workbook takes longer and longer to run and eventually gets to the runtime of 2 hours.  Periodically my user has to go and make a change to the workbook and after he recreates the workbook then it goes back to taking 30 minutes to run.
    Is there some kind of a buffer that is filling up that I don't know about?  Is there a way I can refresh the workbook so that the runtime doesn't creep like it is doing?
    Thanks
    Adam

    Guess I posted prematurely. Looking closer I realized there was a select happening during this process against a text column without an index. The slowdown was just the increasing cost of looping through the the entire dataset looking at strings that often shared a fairly sizable starting substring. Chalk another problem up to the importance of appropriate indexes in your db!

  • The pinwheel is spinning for longer and longer periods of time. Have to manually shut off iMac sometimes to get it to restart.

    The pinwheel is spinning  for longer and longer periods of time. Why and what do I need to do about that?

    You have 10.6 on that machine, I suggest you stick with it for performance, third party hardware and software reasons as long as possible.
    Consider 10.8 (not 10.7) when it's released, because 10.7 and 10.8 will require a new investment in software and newer third party hardware as it requires newer drivers the old machines won't have. (forced upgrade because of software, really nice of them)
    http://roaringapps.com/apps:table
    Far as your Safari problem do these things until it's resolved:
    1: Software Update fully under the Apple menu.
    2: Check the status of your plug-ins and update (works for all browsers) also install Firefox and see if your problems continue. You should always have at least two browsers on the machine just in case one fails.
    https://www.mozilla.org/en-US/plugincheck/
    Flash install instructions/problem resolution here if you need it.
    How to install Flash, fix problems
    3: Install Safari again from Apple's web site
    https://www.apple.com/safari/
    4: Run through this list of fixes, stopping with #16 and report back before doing #17
    Step by Step to fix your Mac

  • Startup process gets longer and longer

    Hi, my parents have an iMac (purchased in 09) running OS X 10.9.5. Over the years and especially lately, the time it takes to startup has gotten longer and longer.
    Any advice or suggestions would be much appreciated.

    Babowa,
    Below are the results of running etrecheck and I apologize for taking so long getting the results to you!  Thanks very much!
    Problem description:
    Startup process takes longer and longer (especially lately)!
    EtreCheck version: 2.1.5 (108)
    Report generated December 19, 2014 at 12:29:58 PM PST
    Click the [Support] links for help with non-Apple products.
    Click the [Details] links for more information about that line.
    Click the [Adware] links for help removing adware.
    Hardware Information: ℹ️
      iMac (20-inch, Early 2009) (Verified)
      iMac - model: iMac9,1
      1 2.66 GHz Intel Core 2 Duo CPU: 2-core
      4 GB RAM Upgradeable
      BANK 0/DIMM0
      2 GB DDR3 1067 MHz ok
      BANK 1/DIMM0
      2 GB DDR3 1067 MHz ok
      Bluetooth: Old - Handoff/Airdrop2 not supported
      Wireless:  en1: 802.11 a/b/g/n
    Video Information: ℹ️
      NVIDIA GeForce 9400 - VRAM: 256 MB
      iMac 1680 x 1050
    System Software: ℹ️
      OS X 10.9.5 (13F34) - Uptime: 0:4:4
    Disk Information: ℹ️
      Hitachi HDT721032SLA380 disk0 : (320.07 GB)
      EFI (disk0s1) <not mounted> : 210 MB
      Recovery HD (disk0s3) <not mounted>  [Recovery]: 650 MB
      Macintosh HD (disk1) / : 318.88 GB (275.79 GB free)
      Encrypted AES-XTS Unlocked
      Core Storage: disk0s2 319.21 GB Online
      HL-DT-ST DVDRW  GA11N 
    USB Information: ℹ️
      Apple Inc. Built-in iSight
      Apple Computer, Inc. IR Receiver
      Apple Inc. BRCM2046 Hub
      Apple Inc. Bluetooth USB Host Controller
    Gatekeeper: ℹ️
      Mac App Store and identified developers
    Adware: ℹ️
      Conduit [Remove]
    Startup Items: ℹ️
      HP IO: Path: /Library/StartupItems/HP IO
      Startup items are obsolete in OS X Yosemite
    Launch Daemons: ℹ️
      [loaded] com.adobe.fpsaud.plist [Support]
    User Launch Agents: ℹ️
      [running] com.zeobit.MacKeeper.Helper.plist [Support]
    User Login Items: ℹ️
      iTunesHelper UNKNOWNHidden (missing value)
      Skype UNKNOWN (missing value)
      Documents FolderHidden (/Users/[redacted]/Documents)
      HP Scheduler Application (/Library/Application Support/Hewlett-Packard/Software Update/HP Scheduler.app)
    Internet Plug-ins: ℹ️
      FlashPlayer-10.6: Version: 15.0.0.246 - SDK 10.6 [Support]
      QuickTime Plugin: Version: 7.7.3
      Flash Player: Version: 15.0.0.246 - SDK 10.6 Mismatch! Adobe recommends 16.0.0.235
      Default Browser: Version: 537 - SDK 10.9
      OfficeLiveBrowserPlugin: Version: 12.3.6 [Support]
      Silverlight: Version: 4.0.60129.0 [Support]
      iPhotoPhotocast: Version: 7.0
    3rd Party Preference Panes: ℹ️
      Flash Player  [Support]
    Time Machine: ℹ️
      Skip System Files: NO
      Auto backup: NO - Auto backup turned off
      Destinations:
      Dic's Thumb Drive [Local]
      Total size: 0 B
      Total number of backups: 0
      Oldest backup: -
      Last backup: -
      Size of backup disk: Excellent
      Backup size 0 B > (Disk size 0 B X 3)
    Top Processes by CPU: ℹ️
          54% Mail
          7% WindowServer
          4% HP Device Monitor
          4% NotificationCenter
          3% opendirectoryd
    Top Processes by Memory: ℹ️
      198 MB Mail
      112 MB mds_stores
      94 MB Microsoft Word
      82 MB WindowServer
      77 MB Safari
    Virtual Memory Information: ℹ️
      1.45 GB Free RAM
      1.63 GB Active RAM
      460 MB Inactive RAM
      483 MB Wired RAM
      422 MB Page-ins
      0 B Page-outs
    Diagnostics Information: ℹ️
      Dec 19, 2014, 12:26:32 PM Self test - passed

  • HT5429 Maps is no longer giving transit instructions????????

    I am very disappointed to find that I can no longer use my iphone to find public transit instructions using maps.  This was my go-to method of independent travel.  Now that I've moved to a city I just found out that maps no longer will find me busses!  I now have had to do research into apps, and use a combination of two apps as well as the metro system website to figure out a simple trip.  What used to be one step has turned into many steps.
    What was apple thinking with this change?????
    I'm living in Seattle and so far have not found an app that performs all the functions of the old iphone maps.

    This option was included with Google maps info which was the maps data provider with the Maps app prior to iOS 6. Google's contract with Apple expired and was not renewed.
    I believe Google provides a free Maps app for the iPhone that may include this option.

  • I'm trying to download maps of the ranch but its taking forever for it to complete. says its enhancing map detail. how long is this going to take????? I need these maps up for work.

    I require google maps of the porperty we manage to do my job I purchased the ifarmer app to help organize and keep better track of details in equipment logs and cattle records. I'm trying to download maps of the property and its taking forever. it says it is "enhancing map detail" but its taken so long the ipod falls asleep and I don't know if that makes it take longer. I also can't do anything else on the ipod until it is done downloading. Is the amount of time its taking to download this map normal????

    Great
    Ok so this is what you need to do:
    You need to put it in DFU mode:
    How to enter iPhone DFU mode
    Connect the iPhone to your computer and launch iTunes
    Turn the iPhone off (hold down the power button at the top of the iPhone)
    Hold down the sleep/power button and home button together for exactly 10 seconds, then release the power button
    Continue to hold down the Home button until a message appears in iTunes telling you an iPhone in recover mode has been detected
    When you are in DFU mode your iPhone Screen will be completely black
    Even though the screen is black, that doesn’t mean the device can’t be interfaced with either iTunes or a custom firmware client (for jailbreaking, etc).
    Remember that if you see the restore logo, itunes logo or any message on the iPhone screen, you are not in DFU mode but standard Recovery Mode. Again, DFU mode is signified by having a completely black screen on the device. If anything else is the case, repeat the steps above until you enter into DFU mode successfully.
    Now you can restore - once restore is completed the Exit DFU mode
    Exit DFU mode on iPhone
    The simplest way to exit out of DFU mode is to hold down the Home and sleep/power buttons on the iPhone while connected to iTunes. Then just hit the power button as and this should reboot the device as usual.

Maybe you are looking for