Modifying a Set without generating a copy of it.

Hello,
My question is, how can I modify the Set I pass to a function directly instead of generating a copy of it. Here's what I mean;
This function will achieve what I want.
       public static Set<String> changeSet(Set<String> passedSet) {
        HashSet<String> changedSet = new HashSet<String>();
        for (String item : passedSet ) {
            changedSet.add(item + "<Changed>");
        return changedSet;
    }However, I have to create a secondary set called changedSet which essentially copies the passedSet with altered items.
How can I iterate through passedSet and modify its items directly? Feel free to let me know if I am on crack and don't make sense.

With immutable objects (e.g., instances of java.lang.String), you'll need to replace the element in the Set.
import java.util.*;
public class Foo {
    public static void main(String[] args) {
        Set<String> set = new HashSet<String>();
        set.add("foo");
        modify(set);
        assert !set.contains("foo");
        assert set.contains("foo<Changed>");
    static void modify(Set<String> set) {
        for (Iterator<String> iter = set.iterator(); iter.hasNext(); ) {
            String s = iter.next();
            set.remove(s);
            set.add(s + "<Changed>");
How can I iterate through passedSet and modify its items directly?If you're passing a set of mutable objects, then just use the foreach loop and modify the object via the reference.
~

Similar Messages

  • How to modify  a table without  setting system to modifiable

    Hi All
    Is there a way to modify a table without setting the system to modifiable either in SCC4 or SE06.
    We locked SCC4 in our system , however one tables are not able to modify.
    table name YAUTM
    Is there a way to bypass this?
    Edited by: Shou Woon Wee on Jan 11, 2008 3:09 AM

    Hi Shou......
    if it gives you a message....."the client is not modifiable"/ ALIAS "table not modifiable"  ...then from a security perspective....you cant, and you might not want to bypass it!
    SCC4 settings are meant to be for that!  Contact your Basis team for this.
    The only way to bypass this is thru ....sending changes through a transport request.
    Curiosity: what environment are you trying this out ? cant be sandbox or DEV!
    Regards
    Abhishek

  • Effective way to copy substring without generating garbage

    Hi,
    I am trying to copy portion of STRING1 to STRINGBUFFER1.
    STRINGBUFFER.append(STRING1.substring(from_index, to_index));
    However, above method generates a String object, then copy its content to STRINGBUFFER, creating garbage.
    Is there some way to do this without generating garbage? Of course, I know I can create a loop and copy one character at a time, but I am afraid that will be slow for huge strings. Thank you in advance.

    Using bothe StringBuilder and StringBuffer there are multiple ways to do what you want.
    Look at the API.
    There are methods for appending char arrays or ranges of CharSequences to a StringBuffer.I am sorry I should have mentioned that I am using J2ME, not J2SE. I looked at the API, but could not find anything.
    And yes, I am trying to avoid garbage as much as possible, because this code gets called quite often.
    Thank you for feedback everyone. I'm still lost with this.

  • Modify jsp files without redeploy

    Hello,
    i modify jsp files without redeploy using tomcat.is there anyone know how
    to enable wls has this future.
    do you have any advice
    Best Regards,
    rechete

    Hey Rechete. Check out "Split Development Directory Environment" which we introduced in 8.1.
    The WebLogic split development directory provides these benefits:
    * Fast development and deployment. By minimizing unnecessary file copying, the split development directory Ant tasks help you recompile and redeploy applications quickly without first generating a deployable archive file or exploded archive directory.
    * Simplified build scripts. The BEA-provided Ant tasks automatically determine which J2EE modules and classes you are creating, and build components in the correct order to support common classpath dependencies. In many cases, your project build script can simply identify the source and build directories and allow Ant tasks to perform their default behaviors.
    * Easy integration with source control systems. The split development directory provides a clean separation between source files and generated files. This helps you maintain only editable files in your source control system. You can also clean the build by deleting the entire build directory; build files are easily replaced by rebuilding the project.
    http://e-docs.bea.com/wls/docs81/programming/environment.html#1097239

  • In STO, system allowing to make invoice without generating PGI

    Dear All,
    We are using SAP ECC 6.0, in stock transfer STO - Delivery - PGI - Invoice - excise invoice, this procedure we are using. Now error which has been noticed is that without generating  PGI, system is allowing to make excise invoice in the system. Requirement is that system would not allow to make invoice without generating PGI in the system. Anybody can help in this matter.
    Thanks in advance.
    Madhukar Mittal

    Hi,
    go to Txn.VTFL Under Header chose the item category and change the copying requirements change from 11 to 3.
    Regards
    GK.
    Edited by: Gnana Kumar on Oct 7, 2010 7:01 AM

  • Urgent:How to modify a script without changing the print programme

    Hi all,
    Can any body pls tell me <b>How to modify a script without changing the print programme</b>
    Give m esome real time examples.
    Good points willbe rewarded
    Thanks

    Hi
    You can write a external Subroutine to fetch the extra data into the script program
    see the following sample code
    How to call a subroutine form SAPscripts
    The Form :
    /:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
    /:USING &EKKO-EBELN&
    /:CHANGING &CDECENT&
    /:ENDPERFORM
    The report :
    REPORT zkrpmm_perform_z1medruck .
    DATA : BEGIN OF it_input_table OCCURS 10.
    INCLUDE STRUCTURE itcsy.
    DATA : END OF it_input_table.
    déclaration de la table output_table contenant les
    variables exportées
    DATA : BEGIN OF it_output_table OCCURS 0.
    INCLUDE STRUCTURE itcsy.
    DATA : END OF it_output_table.
    DATA : w_ebeln LIKE ekko-ebeln,
    w_vbeln LIKE vbak-vbeln,
    w_zcdffa LIKE vbak-zcdffa.
    FORM CDE_CENT
    FORM cde_cent TABLES input output.
    it_input_table[] = input[].
    it_output_table[] = output[].
    READ TABLE it_input_table INDEX 1.
    MOVE it_input_table-value TO w_ebeln.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = w_ebeln
    IMPORTING
    output = w_ebeln.
    SELECT SINGLE zcdffa FROM ekko
    INTO w_zcdffa
    WHERE ebeln = w_ebeln.
    it_output_table-name = 'CDECENT'.
    MOVE w_zcdffa TO it_output_table-value.
    MODIFY it_output_table INDEX 1.
    output[] = it_output_table[].
    ENDFORM.
    COPING SCRIPT
    There are some Standard Sap Scripts in SAP. We cant directly execute them in scripts we have to use some T-codes and by giving some input to the required fields we can see the output printform.
    I will show one example. There are some Standard Sap Scripts such as MEDRUCK which is a standard Sap Script for Purchase Order and RVINVOICE01 for billing and so on...
    To see oupt of MEDRUCK go to T-code ME9F give purchase order number and execute select one number and click on dislplay messages button on application tool bar you can find the print form of MEDRUCK.
    You cannot change the Standard Sap Scripts but you can use Standard Sap Scripts and Copy them to userdefined Script and can make changes to them and replace standard Sap Script with usedefind script.
    Ex: Go to SE71,
    on menu bar u find Utilities->copy from Client. click on it u ll find new screen showing
    Form name:
    Source Clinet:
    Target Form:
    give Form name as usedefined form name EX: ZFORM1
    Source client as 000 and
    Target form as MEDRUCK.
    execute.
    Now, the standard from MEDRUCK is copyied to your form ZFORM1.
    NOW, go to SE71 and give form name as ZFORM1 and do some changes to the form such as adding logo any thing. save and Activate.
    Now, you have done changes to the Form ZFORM1 and u have to replace your form with standard SAP Script.
    Go to NACE Transaction.
    on Applications select EF for purchase order and click Output types button on application tool bar.
    now select NEU as output types dobule click on Processing Routines.
    now click on Change option on application tool bar and on right side u find MEDRUCK in form place replace MEDRUCK with ZFORM1 and SAVE.
    go back twice and now go to T-code ME9F give the purchase order number and execute and select one option and click on display messges button .
    you will find the changes that you have done in ZFORM1. so we cant chage the standard Sap Scripts by copying the Standard Sap Scripts we can chage and replace with our forms
    Refer
    https://forums.sdn.sap.com/click.jspa?searchID=4089895&messageID=3239299
    Regards
    Message was edited by:
            Kiran Sure(skk)

  • Help: how to modify a setting for a running

    solaris 10 10/05 on sUN E3000
    Q: how to modify the setting for a running zone.
    I want to add a lofs mount for /usr/local read/write.
    also I want to add access to cdrom
    so I use zonecfg to "add fs ", and stuff then commit.
    now what should I do to make effect in the zone.
    thanks.

    to rephase my question:
    once I have a zone installed, is there a way to
    modify the zone settings , such as adding a fs
    or devices, without destory the zone? thanks.

  • Issue with the functions "add matching sets" and "modify matching sets"

    Hi,
    Though 'None' access permission is set for the functions 'Add Matching Sets' and 'Modify Matching Sets', they are accessible.
    Is this a bug with the tool? or am I missing something?
    Thanks in advance,
    Madan

    sorry, missed the version details.
    I'm using MDM 5.5 SP6.

  • I got a new ipad mini and chose to set up as a copy of my iPad.  Didn't sync the music on however as it is a smaller model, not enough room.  Now trying to get some pictures and music on.  Chose some pictures that were not in iPhoto, got a message that I

    I got a new ipad mini and chose to set up as a copy of my iPad.  Didn't sync the music on however as it is a smaller model, not enough room.  Now trying to get some pictures and music on.  Chose some pictures that were not in iPhoto, got a message that I could only sync with one library, chose cancel, and apply and it downloaded my pictures anyway.  Now trying to sync some music but just get "The iPad “Linda’s iPad” is synced with another iTunes library. Do you want to erase this iPad and sync with this iTunes library?"  So I hit cancel.  Have tried several times, same thing. What can I try?

    You should be able to accept this message, it will cause existing music, photos (not camera roll) and videos (also excluding those in camera roll) to be removed and replaced with those from this computer. All other user data on the iPad will be unaffected.

  • How Can I restore my ipod shuffle to factory setting (without all the software updates)?

    After updating my ipod shuffle, my car no longer recognize it. I cannot connect it to my car via usb. For the past few weeks I have been listen to only songs on the radio. I tried to restore it, but fond out that all it did was removed all my songs ect, but the update is still the most current version. Please someone, please help me. How can I restore my ipod shuffle to the original factory setting without all the update.

    You may have the accessibility VoiceOver feature or another one turned on.
    Triple click the home button and try going to Settings>General>Accessibility and turn VoiceOver off and any others off. You may have to use three fingers to scroll the screen to get there. If problems see the following for how to turn off via iTunes:
    iPhone: Configuring accessibility features (including VoiceOver and Zoom)
    Next try:
    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup. See:                                 
    iOS: How to back up                                                 
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar                       

  • Looking for an app that I can save what I highlight when I am reading an article without having to copy and paste

    Looking for an app that I can save what I highlight when I am reading an article without having to copy and paste

    I looked at Bento and at first glance I think it would do everything I want it to do, then I saw a review or something from a customer that indicated the information in Bento could not be exported (say to send out a mailing).  I may want a program that can do that as well, is there one out there? If not it does look like Bento will work.  When you save a picture to a customer in Bento can you open it up full size?

  • HT3728 My Time Capsule is working fine with ethernet connection, but it is no longer working with wifi, probably because of my wrong setting; is there a way to reset wifi setting without losing backuped data? Thanks you all

    y Time Capsule is working fine with ethernet connection, but it is no longer working with wifi, probably because of my wrong setting; is there a way to reset wifi setting without losing backuped data? Thanks you all

    Giancarlo Messalli wrote:
    1) are you sure a reset holding the reset button will not delete my data?
    Absolutely sure.. There is no connection at all.. reset is only the router side of the TC.
    For the hard disk to be erased you need to access the airport utility disk page.. request erase and confirm the operation.
    2) I can access to time capsule by ethernet but I am not able to input the corret setting by myself
    Thank you again
    I am uncertain why if you have access you cannot change settings.. but that is why you reset things so any of those problems should be fixed.
    Here is the Apple info on reset.
    http://support.apple.com/kb/ht3728
    And here is the quote from the horse's mouth so to speak.
    Factory default reset: Perform this reset if you wish to repurpose the AirPort Base Station or Time Capsule and want to remove all personal profiles and settings first. This reset resets the device to its state when you first purchased it. Data stored on internal or external hard drives connected to the device will not be erased. If you choose, you may manually erase the hard drive using AirPort Utility.

  • Is there a way I can use my external hard drive without the files being transferred on to my computer? as like like my iTunes music being on my hard drive without them being copied onto my computers hard drive ?

    is there a way I can use my external hard drive without the files being transferred on to my computer? as like like my iTunes music being on my hard drive without them being copied onto my computers hard drive ? because i dont have that much memory and i wanted my external hard drive to be the source for my music files and not my computer.

    Many users keep their iTunes libraries on external drives. You just have to remember to connect and power up the drive before launching iTunes.
    iTunes for Mac: Moving your iTunes Media folder:
      http://support.apple.com/kb/HT1449 

  • How do I install Windows 8 via ISO onto a modified MBP 2010 without an optical drive?

    I have a modified 2010 MBP without an optical drive. I'm trying to install Windows 8 through bootcamp by creating a USB disk, but Startup Disk does not recognize this USB. How do I install my Win 8 ISO? Thanks in advance

    I can kind of help you here. First you will need to find out if your computer can install Windows 8. The following computers can install Windows 8
    MacBook Air (Mid 2011 or newer)
    MacBook Pro (15-inch and 17-inch, Mid 2010 or newer)
    MacBook Pro (13-inch and 15-inch with retina display, Mid 2012 or newer)
    Mac Pro (Early 2009 or newer)
    Mac Mini (Mid 2011 or newer)
    iMac (27-inch, Mid 2010 or newer)
    iMac (21.5-inch, Mid 2011 or newer)
    Your computer MUST have Boot Camp 5 running on Mac OS X 10.8.3 Mountain Lion or later other wise Windows 8 will not work.
    If you don't have one of those computers it won't allow you to install Windows 8. You can try getting a Windows 8 install disc and an external optical drive that supports Mac OS X. I reccomend the Soniq Slim DVD-RW Drive becuase it works with almost every disc including install discs. But before trying to use an install disc with an external optical drive make sure you go into boot camp assistant and remove the partition that you made for Windows. If this didn't help you go to Apple's Boot Camp FAQ for Windows 8. The link is below.
    http://support.apple.com/kb/HT5628?viewlocale=en_US&locale=en_US
    Hope this helped!

  • I have files in my iTunes media folder that somehow are not in my library. How do I get iTunes to scan my media folder and add missing files to my library without making a copy of each file in the same location?

    I have files in my iTunes media folder that somehow are not in my library. How do I get iTunes to scan my media folder and add missing files to my library without making a copy of each file in the same location? If I use add file / folder to library, it scans the folder and then makes a copy of any file that is not in my library in the exact same location; I recal in older versions of iTunes being able to just drag my media folder into my library and it would update missing links.

    Only the songs that are connected to iTunes will be copied when you consolidate to a new folder.
    Splitting the media folder away from the usual location makes it harder to move iTunes in the future.
    Are you go move everything back once you've tidied up or are you going to leave it that way? Either way I'd recommend you create an iTunes folder at the new location, an iTunes Media folder inside that, and consolidate to this new iTunes Media folder. You should also use the option File > LIbrary > Organize Library > Rearrange files in the folder "<Media Folder"> if you have not already done so.
    tt2

Maybe you are looking for

  • How can I add a row into a JTable with JButton

    Hi all. I have the following code: package gui; import db.*; import javax.swing.table.AbstractTableModel; import java.util.ArrayList; public class FoundersTable extends AbstractTableModel{     private static final int COLUMNS = 8;     private String

  • Set Up/Conversion Opinions on g5 to 8 core

    I'll rec my 8 core in a few hours and am looking for advice to how to convert my g5 computer/data. It's tempting to use the fire wire/apple converts during set up - but... 1. Might this overwrite g5 aps over native apps. 2. will this convert my itune

  • Inbound XML IDOC to IDOC

    I've searched the internet for solutions but I have not seen any solutions.  I'm trying to upload an XML IDOC (generated from SAP) back into SAP using IDOC_XML_FROM_FILE.  I've configured the my XML port to see the directory where the idoc is stored

  • I want to insert an image among text... how can I ?

    Nice day webmates : I am trying to insert a small logo in between text... so that if for example I type something like this : This text is for example on behalf of my [LOGO] because I need that [LOGO] be displayed here as an image.. How do I do that

  • What is with the app?

         I recently bought "Grand Theft Auto: Vice City" for my iPad for $5, but every time I download the app it just stops. Below the app, where it should say loading, the name pops up. The only problem is the blue loading bar is still on the app, not