Make unique array of structure

Hi all.
How can make array of unique elements ?
Heed to get from array -> array1
<cfset array = arrayNew(1) />
<cfset array1 = arrayNew(1) />
<cfset array[ 1 ] = { id = '1' } />
<cfset array[ 2 ] = { id = '1' } />
<cfset array[ 3 ] = { id = '1' } />
<cfset array[ 4 ] = { id = '2' } />
<cfset array[ 5 ] = { id = '3' } />
<cfset array[ 6 ] = { id = '4' } />
<cfset array[ 7 ] = { id = '4' } />
<cfset array[ 8 ] = { id = '5' } />
<cfdump var="#array#" label="Current" />
<cfset array1[ 1 ] = { id = '1' } />
<cfset array1[ 2 ] = { id = '2' } />
<cfset array1[ 3 ] = { id = '3' } />
<cfset array1[ 4 ] = { id = '4' } />
<cfset array1[ 5 ] = { id = '5' } />
<br /><br />
<cfdump var="#array1#" label="Needfull" />

There are a few 'tricks' that you can use here ...
A "struct" is fundamentally an associative-array structure.  So, if you've got an "id" field of any sort, a struct can locate any "id" almost instantly.  This is much faster than searching an array (which has a hidden cost created by virtual-memory paging over a large "footprint").
When you add a struct to another struct or to an array, you are actually moving a reference to the structure.  You should find that (afaik!), if the struct is present both in an array and in a struct, both of these are references to one-and-the-same memory block.
Use the most-convenient data structure when building the original set of records.  This is probably going to be a "struct."  If you then need to have an array of elements sorted in a particular way, build that array last, by using a "sort" operation to arrange the records in whatever order you want.  Since you'are actually (afaik...) moving references, you're not stomping on too much RAM.
"Sorting" is what I call an "unexpectedly fast and efficient" operation, because it's one of the most heavily-studied operations in all of data processing ... and has been since the days of Herman Hollerith.

Similar Messages

  • Accessing Array of Structures from Coldfusion

    I am having a problem accessing an array of structures from
    Coldfusion within my flex application. Here is how I make my Array:
    (GetRegions is a type Query and Type is a string variable)
    <cfset ReturnArray = ArrayNew(1)>
    <cfset ReturnArray[1] = StructNew()>
    <cfset ReturnArray[1].Query = GetRegions>
    <cfset ReturnArray[2] = Type>
    Within flex I am trying to access the results in the
    following way:
    private function dataHandler(event:ResultEvent):void{
    Query_Filter = new ArrayCollection(event.result[0].QUERY as
    Array);
    myString = event.result[1] as String;
    Can anybody help me with this. I want a way to return a query
    and a string back from coldfusion.
    Thanks for the help,
    Jeff

    So now I changed my code to the following in CF:
    <cfset Type = "MyString">
    <cfset ReturnArray = ArrayNew(1)>
    <cfset ReturnArray[1] = StructNew()>
    <!--- set up query GetRegions --->
    <cfset ReturnArray[1] = GetRegions>
    <cfset ReturnArray[2] = Type>
    <!--- Return Array --->
    <cfreturn ReturnArray>
    Now in flex I have the following dataHandler Function:
    Alert.show("hello: "+ObjectUtil.toString(event.result[0]));
    Query_Filter = new ArrayCollection(event.result as Array);
    Now I set up a List box with Query_Filter as the dataprovider
    but the results aren't showing correctly. The first item in the
    list box is displayed as [object, Object], [object, Object] and the
    second item is my String.
    Does anybody know how to break up the query to a variable and
    the string to its own variable in the dataHandler function.
    Thanks for any and all help

  • Passing an array of structures to an Oracle stored procedure (CFMX)

    I'm looking to write a Oracle stored procedure where I would pass in an array of structures and loop over each iteration to insert the bits and pieces within the structures to the DB.,
    I haven't written this type of procedure / package before.  I am planning to do an sp / package similar to what is sketched out in the second reply to this thread: http://forums.oracle.com/forums/thread.jspa?threadID=1078772
    Assuming I do, how can I call the procedure from ColdFusion (I'm using MX) and pass in my array?  As far as I can see, none of the CF_SQL_Types make sense.

    Let me know if you make any progress.  I'm fighting the same battle.  What I've done so far is to convert my array of struct into a delimited CLOB that looks like this:
    prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|prop1;prop2;prop3|
    Then I wrote a stored proc to suck it up using a pipelined function.  It's not to bad but parsing the CLOB on the ORACLE side is somewhat time consuming.
    I've also converted the array to XML and used dbms_xmlstore to convert but, on large arrays, it is very slow and the CLOB gets huge fast.
    I was hoping to use the cf_sql_refcursor but I can't figure out how.
    Warren

  • Array of structures - two ways to approach - which is better?

    Folks - I've been trying to create an array of structures,
    but I bumped into problem that lead me to an example that is
    completely different. I'm trying to figure out which is valid. In
    general, it comes down to this:
    (1) myStructure
    .firstName
    vs
    (2) myStructure.firstName
    The problem with the first is that I can't find a way to
    discover the size of the array, which leads me to suspect this is
    not a valid method. The problem with the second is that you must
    redefine the structure for EACH array element, which seems like it
    would add a lot of overhead.
    Any advice? Sample code attached.
    Thanks!
    ************* Sample (1) **************
    <CFSET sCust=StructNew()>
    <CFSET vCustCount = #rsMailAuth.recordcount#>
    <CFSET i = 0>
    <CFOUTPUT QUERY="rsMailAuth">
    <CFSET i = i+1>
    <CFSET sCust.userId
    = #rsMailAuth.userId#>
    <CFSET sCust.validEmailSource =
    #rsMailAuth.validTcEmails#>
    <CFSET sCust.authKeyword
    = #rsMailAuth.tcEmailKeyword#>
    <CFSET sCust.authKeywordLoc =
    #rsMailAuth.tcEmailKeywordLoc#>
    </CFOUTPUT>
    ************* Sample (2) **************
    <cfset strTest = arrayNew(1) >
    <cfset strTest[1] = structNew() >
    <CFLOOP INDEX = "i" FROM="1" TO="5" >
    <cfset strTest
    = structNew() >
    <cfset strTest.id = i>
    <cfset strTest
    .name = "[email protected]">
    </CFLOOP>
    <cfoutput>#arrayLen(strTest)#</cfoutput>

    Sorry - simple english...
    I am collecting a series of emails from a pop email server.
    As I parse these into the individual parts (subject, body, from,
    etc) I want to stuff them into a structure. each email would be a
    new index. so, the 2nd email 'from' info would go into
    myStructure.from[2] or myStructure[2].from.
    I know there are lots of ways around this, I just have a
    natural predisposition to use structures when possible as it makes
    it easier for me to keep track of things and makes it easier to
    follow the code.
    I can make either of these work, I'm just not sure if they
    are valid in the world of coldfusion8.

  • Loops in arrays or structures

    Loops in arrays or structures
    I was given a project on html reports and
    They have advised me to use Loops in arrays or structures
    At this point I am a novice at this html reporting system. I
    would like to know how I can use loops in arrays or structures.
    How is it beneficial are
    1. Structures
    2. Arrays
    3. loops in for both
    for my reports.
    Countless thanks in advance

    Structures are great if you understand them, they are
    basically just arrays organized by keywords rather than index
    numbers.
    Arrays are very nice, as you can just run through loops to
    access each element, as they are all indexed by numbers 0-x.
    loops are great to navigate through both. All you have to do
    is set an loop to run through x amount of iterations of the array
    or structure (where x is the length of the array, or number of
    elements in the structure). Loops are great due to the small amount
    of code they require.

  • How do you make an array of image icons and then call them?

    How do you make an array of image icons and then call them, i have searched all over the internet for making an array of icons, but i have
    found nothing. Below is my attempt at making an array of icons, but i cant seem to make it work. Basically, i want the image to match the value of the roll of the dice (rollVal)
    Any help would be greatly appreciated, some code or link to tuturial, ect.
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image  ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
              j1= new JLabel("");
           die =new Dice();
           int rollVal;
           rollVal = die.roll();     
           image = new  ImageIcon[images.length];
         for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    Demo:
    import java.awt.*;
    import java.net.*;
    import javax.swing.*;
    public class IconExample {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch();
        static void launch() {
            try {
                Icon[] icons = new Icon[6];
                for(int i=0; i<icons.length; ++i) {
                    String url = "http://www.eureka-puzzle.be/cast/images/dice" + (i + 1) + ".jpg";
                    icons[i] = new ImageIcon(new URL(url));
                display(icons);
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
        static void display(Icon[] icons) {
            JPanel cp = new JPanel();
            for(Icon icon : icons) {
                cp.add(new JLabel(icon));
            JFrame f = new JFrame();
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Is it possible to make an array of JButtons?

    is it possible to make an array of JButtons?

    Note that this doesn't create any JButtons, just the array!

  • ABAP program to make a Hierarchy flatfile structure?

    Hi,
    Is there any ABAP program by which we can make a flat file structure in the conventional format ? ( Nodeid,Infoobject,Nodename etc---)
    Because here i just cannot make the flat file manually as the document i have is huge one, having somany nodes and levels that it is almost impossible to write down on a paper too!
    Any suggestions?
    Thanks,
    Ravi

    Hi,
    I have used the following function modules to breakdown the hierarchy. You can write a simple abap program and download the heirarchy breakdown.
    CLAF_CLASSIFICATION_OF_OBJECTS - this function module will return the class information for the hierarchy.
    Use the internal table i_class (filled by the above function module) and pass the relevant fields to the FM CC_LS_GET_CLASS_HIER_STRUCTURE.
    The entire hierarchy then becomes available in the table 'class_structure'. Use appropriate methods to download to the presentation ( FM WS_DOWNLOAD GUI_DOWNLOAD) / application servers (OPEN Dataset/Transfer Dataset/CLose dataset).

  • Add "make unique symbol" button and context menu option

    I often want to make a variation of an existing symbol that is already positioned on the page. Unless I'm missing something, the steps are to duplicate existing symbol in the symbols palette, then replace the selected symbol instance, using the "replace symbol instance" in the Control Bar. Why not have a context menu option "make unique symbol" that automatically replaces the instance with new, unique symbol? I'd also like to see "Edit Symbol" added to the context menu. I'm hovering over the symbol, why should I have to go find the "edit symbol" button? I realize I can double-click the instance, but this does not work in all cases, such as when the direct select tool is active.
    If you've used SketchUp, you know where this idea comes from.
    Thanks,
    Ray

    No, I want to make a new, unique symbol of an existing symbol instance. If I choose "break link" from the context menu or symbols palette, the artwork is no longer a symbol and after editing, must converted to a symbol using the symbols palette. This requires several, unnecessary steps. At the very least, I'd like to see "Make new symbol" added to the context menu. If you're a SketchUp user you'll know exactly what I'm talking about. Seems incidental, but AI's method is inefficient.

  • How to create an array of structure which the structure contain an array(s)

    im very new to java, and new here
    i searched many websites, but i cant find it
    it looks like this,
    there is 10 employees, each of them has 0-5 children,
    what i want is,
    peter alan joseph
    |?????????????????|???????|??????????????
    | |????????| |??????| | |?????| |
    | | andrew | | alvin | | | john | | ...........................
    | |________| |______| | |_____| |
    | |
    what i know is,
    import java.util.*;
    class main{
        public static void main(String[] args){
              employee d[] = new employee[10];
              d[0]= new employee();
              d[0].child = "alvin";
              System.out.println(d[0].child);
    class employee{
        String child;
    }but only work for 1 child.. =(
    i need an array of structure which the structure itself cantains an array(s)
    please help, newbie here

    sen,
    my lecture[r] said no statement in classEither you misundetstood your lecturer [probable]; or your lecturer is full of shit [possible].
    is "String[] children = new String[5]" a statement ?Yes, it is.
    she said we can only declare like "String[] children;" in classEither you misundetstood your lecturer ...
    There's nothing actually wrong withclass Employee{
        String[] children = new String[5];
    }But it has the inherent limitation that you can't put the fathers name on the 6'th child's birth certificate... because the dumb computer won't let you... Hence it is poor practice.
    A better implementation would be:class Employee{
        private List<String> children = new ArrayList<String>();
    }because it doesn't impose an artificial limit on the number of kids a bloke can have.
    keith.

  • How to pass an array or structure, in addition to a query, or multiple queries to the Report Builder as parameters

    Is there a way to pass an array or structure for example as parameters, in addition to a query, or multiple queries to the Report Builder in CF8? I believe this was recommended by users to be in CF8.

    BrianO,
    Although it's been a while, I thought I'd provide the code to do this for you. It works for me in CF8, and probably will in CF7.
    Here I create a structure called My, and provide that one parameter to my CFReportParam tag.
    <CFSet My = {
    Client = "Client Name",
    ReportDateFrom = DateFormat(ThisStartDate, DateMask),
    ReportDateTo = DateFormat(ThisEndDate, DateMask),
    PageHeaderImage = ImagePath & "\Logos\Page_Header.png",
    WatermarkImage = ImagePath & "\Logos\Watermark.png",
    GetBarSummary = GetBarSummary,
    GetPieSummary = GetPieSummary
    }>
    <CFReport Template="#ReportPath#\SpendSummary.cfr" Format="PDF" Query="GetSummary">
    <CFReportParam Name="My" Value="#My#">
    </CFReport>
    Inside the report itself, reference the given parameter as Param.My.PageHeaderImage for example. It can be referenced that way from any expression inside the report builder. You can even use the queries as the data source for charts (using the Data From a Query -> Query Builder -> Advanced) by entering "Param.My.GetPieSummary" where it says "Variable containing query object".
    HTH
    Swift

  • How to pass a structure/array of structure as input parameter in a webservice

    Hi Team,
    I am trying to create a webservice in powerbuilder .net( pb 12.5.1) . As this webservice will be used by external world to access some of data on basis of some input paarameter.
    So can i use array of structure as input parameter to a webservice ? If no, then how can i pass a result set ( mora then 1 row with more than one column)
    as an argument to the webservice.
    Regards
    Subrat

    I am assuming this is the same for .Net but in Classic you can create NVO's with Instance Variables and then reference them in the NVO that will be used as the parameter for the Public WebService.
    WS NVO's:
    Children
         String             Child[]
    Customer
         String             FirstName
         String             LastName
         String             DOB
         Children          Children
    Public Interface uses Customer
    Calling Code Example:
    integer    rc, liNdx
    string     lsReturn
    SoapConnection lSoapConnect
    proxy_testing  px_Testing
    lSoapConnect = CREATE SoapConnection
    if IsValid(lSoapConnect) then
    TRY
      rc = lSoapConnect.CreateInstance(px_Testing, 'proxy_testing')
      CHOOSE CASE rc
       CASE 100
        lsReturn = "Invalid proxy name"
       CASE 101
        lsReturn = "Failed to create proxy"
       CASE 0
        Proxy_Customer lNewCustomer
        lNewCustomer = CREATE Proxy_Customer
        lNewCustomer.FirstName = 'Chris'
        lNewCustomer.LastName = 'Craft'
        lNewCustomer.DOB = 'Getting Older'
        Proxy_Children lChildren
        lChildren = CREATE Proxy_Children
        lChildren.Child[1] = 'Madeline'
        lChildren.Child[2] = 'Hayden'
        lNewCustomer.Children = lChildren
        lsReturn = px_Testing.NewCustomer(lNewCustomer)
       CASE ELSE
        lsReturn = "Unknown error (" + String(rc) + ")"
      END CHOOSE
      if rc <> 0 then MessageBox("Invocation Error", lsReturn, Exclamation!)
    CATCH (RuntimeError rte)
      rc = -1
      MessageBox("Runtime Error", rte.text, Exclamation!)
    END TRY
    end if
    Chris Craft

  • How Do I have to Make Mesh for Small Structures in MWO?

    Hi there,
    I am using AWR Microwaveoffice in order to simulate the electromagnetics of nanomechanics. The unit length of the nanomachanics was 1um and the minimum dimension of the structure was about 15 um. I made mesh and simulated the circuit using the AXIEM solver. However, the result was absurd -- the linewidth of the S12 parameter was about 100 times larger than the experimental value. I found out that the mesh shape was odd; as shown FIG.1, the mesh was not reflecting the shape of the circle and the combs. Thus I think that the mesh settings were wrong. Could you please tell me how to make mesh for small structure in MWO? And also I don't know what the large rectangle in FIG.1 means.
    Solved!
    Go to Solution.
    Attachments:
    FIG.1.png ‏25 KB

    Hi
    Thanks to your replies, I succeeded to make the mesh as shown in the attached photo. However, I still have a problem; I cannnot find any dips in the resulting |S12| graph, which is suppoesed to have a sharp dip between 5 GHz and 15 GHz. I tried to figure out the reason but I couldn't. Could you help me plesase?
    Attachments:
    mesh2.png ‏143 KB

  • The suitable LabVIEW data type correspinding to the array of structure in Visual Basic ActiveX DLL

    Hi!
    I need to call a VB ActiveX DLL from LabVIEW. When I run my LabVIEW code, I always meet an error as:
    Error 1 occurred at Incorrect Function in T06.vi
    Possible reasons:
    LabVIEW: An input parameter is invalid.
    I have read the VB DLL code that defines the data type. It fills data to a structure, then puts this structure to the array, and sends the array of structures to the method.
    VB Code:
    For I = 1 To 31
    Set MyInputData(I) = New EM_nkd_DataPoint
    Next I
    With MyInputData(1)
    .Amplitude = 8.44
    .DataPointType = R_HW
    .DataSource = MEASURED
    .Wav
    elength = 409.56
    End With
    With MyInputData(2)
    .Amplitude = 91.60113
    .DataPointType = T_SUB
    .DataSource = MEASURED
    .Wavelength = 409.56
    End With
    ~~~
    With MyInputData(31)
    .Amplitude = 91.96825
    .DataPointType = T_SUB
    .DataSource = MEASURED
    .Wavelength = 657.43
    End With
    My problem is that I can’t find a suitable kind of data type in LabVIEW which is corresponding to this case
    Attached my LabVIEW code for reference.
    Many thsnks.
    TX
    Attachments:
    T07.vi ‏166 KB

    Hi,
    if you have a complete source code including EM_nkd_DataPoint class module, take a look inside in order to see data types for Amplitude, DataPointType, DataSource and Wavelength (probably for Amplitude and Wavelength is SINGLE). If this code is not available, maybe the author mentioned a type for T_SUB and MEASURED even if they are constants.

  • Add "make unique symbol" to the symbol context menu

    There are many times I need to make a "variation" of a symbol that should also become a symbol. The current method requires several unnecessary steps. I'd like an option in the "Symbol" context menu called "Make unique Symbol". It would duplicate the current symbol in the symbol palette and link the current symbol instance to it.

    I agree the context menu entry is useful and I also use TMP for it. Firefox does have a built-in option to duplicate a tab. Hold down the control key, then drag the tab onto the tab bar and it will create a duplicate.
    You may already be aware, but there is a development version of Tab Mix Plus for Firefox 4 available from http://tmp.garyr.net/forum/viewtopic.php?t=10888

Maybe you are looking for

  • Please shed some light on Chunked Transfer Coding for HTTP 1.1?

    I am writing a HTTP proxy in Java, but I have a problem. I am writing a HTTP 1.0 proxy. As you probably know, HTTP 1.0 determines the length of the message body using Content-Length and HTTP 1.1 server are supposed to send a Content-Length header to

  • XREF and DVM in OSB 11g

    Hi everybody, I'm trying to find out if domain-value maps (DVM) and cross-reference tables (XREF) are supported for OSB 11g. We have only OSB licensed, not SOA Suite. OSB statement of direction states that these features will be supported. This blog

  • Error while starting BPEL

    Hi All, I have successfully installed the Oracle BPEL Process Manager with the BEA WebLogic Server 10. But during startup of the oracleBPELServer server from weblogic console I get the following exception! So I included the jsafeFIPS.jar in "server s

  • Azure backup services for Object Storage

    I'm investigating using your Object Storage services for our on-premise application. I see there are replication options for this service but I assume all the replicas are near real-time. I want to be protected from something horrible like an applica

  • Special Procurement and In-House Production on the same plant?

    Hi All, There is a Plant A and Plant B. Plant A makes its own stock of material Z and sometimes gets it from Plant B as well through STO. For such cases where a plant gets stock from another stock, we have a special procurement type configured with t