Thread: [KT/JAVA] Efficiently shift your Item arrays (also complementary item class)

Results 1 to 1 of 1
  1. #1 [KT/JAVA] Efficiently shift your Item arrays (also complementary item class) 
    nbness2#5894

    nbness2's Avatar
    Join Date
    Aug 2011
    Posts
    626
    Thanks given
    238
    Thanks received
    113
    Rep Power
    256
    Hey, I see people that struggle with Item Container shift bugs so I'm here to give you 2 (4) ways of shifting your items without bugs!
    This is just some simple code that allows you to shift all of your items LEFT. An example usage would be the bank. Take out the first item, all items now shift left. That's what this does.
    ItemContainer is a super simple container that literally only has the shift functions. A much more fully featured Container is coming soonish.

    The two shifts:
    • Memory Friendly
      • This one is much more memory friendly but also much slower (~twice as slow) for Containers over 155 items.
    • Fast Shift
      • This one is much faster (~twice as fast) for containers over 155 items but also uses a lot more memory (because of the partitionJoin mainly).


    In reality, the time difference is not big at all. As long as you aren't doing hundreds of shifts per second on randomly distributed Containers, performance shouldn't be too big of a problem for you if you aren't worried about memory.
    Bank size (450-500 items) is ~0.03ms for memory friendly, ~0.0065ms for fast shift

    Sorry if the java is sloppy, what I wrote is more than I've written in the last year. Juck Fava.
    Repo: [Only registered and activated users can see links. ]

    The performance test was written in kotlin, executed on amd64 Ubuntu 18.04, R7 1800X.
    Performance Graph - Plot.ly: [Only registered and activated users can see links. ]

    Spoiler for New kt Container Peek:

    Container will promote safe usage and error handling rather than try catching everything using something similar to Java's Result.
    This is meant to be used in Kotlin (it will look and feel nicer in kotlin), though you can use it in Java if you really must.







    For those of you who like to live dangerously

    KT/JAVA - NBX 637 - [Only registered and activated users can see links. ]!
    KT - Drop tables made Easy and Readable - [Only registered and activated users can see links. ]!
    KT - Item Containers made Safe, Easy and Powerful - 2019/05/04 UPDATED V2 - [Only registered and activated users can see links. ]
    KT - Utils to make your life easier - [Only registered and activated users can see links. ]
    KT - Hopping Islands: From Java to Kotlin - [Only registered and activated users can see links. ] - [Only registered and activated users can see links. ] - [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. Thankful users:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 06-15-2012, 09:08 PM
  2. Updating Item Array
    By The Wanderer in forum Help
    Replies: 2
    Last Post: 11-25-2011, 11:32 AM
  3. Replies: 8
    Last Post: 10-11-2009, 10:37 AM
  4. Replies: 42
    Last Post: 01-05-2009, 01:31 AM
  5. Item array interfaces
    By Palidino in forum Configuration
    Replies: 14
    Last Post: 11-16-2008, 05:34 PM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •