Overloading operators

Hi, just like I've said in my previous posts I'm fairly new to java and I have c++ background, so my questions are rather based on the fact that I would like to know how to do this same things in java as I use to do in c++. So my question is - How can I overload operators in java?
Thanks for replies.

tjacobs01 wrote:
sjasja wrote:
You can't.Well, actually you can, kind of in the same way that "a" + "b" is overloaded. Nope. That is not overloading. No more so than adding a int to a double in java is overloading. No more so than string concatenation in numerous programming languages is overloading except in C++ where string concatenation is overloading.
The JLS defines concatenation using the plus operator.
The C++ ANSI spec defines operator overloading. It doesn't define string concatenation.
In any discussion of overloading where C++ is the source then it does not mean the same thing.

Similar Messages

  • Overload operators

    Hello!
    Does someone know if in JAVA there's a way to overload operators (=, +, *, ....) in a way similar to that of C++.
    I know that I could write a method in which I put my operator and all the actions I want to do... but I can't do this because I'm analyzing a very large application already written... and my purpose is only to be notified when operators (in this case =) is applied to some objects.
    Thank you very much all in advance.
    Diego

    Thank you sabre. Do you know if there's a way to
    trace objects which own a reference to other objects?
    ... I means objects which obtain reference to an
    object thanks to an assignment (=).No I don't know a way to trace objects which own a reference to other objects.

  • Operators Overloading

    How can I overload operators in Java (if I can at all)?

    that's not possible in java.
    use functions instead.that's not possible in java.
    use methods instead.

  • Java features

    Hello,
    I would to know if this extract, written in 2004, is still topical with the current version of Java.
    Delegates and indexers
    The Java language doesn't have a construct directly equivalent to a C# delegate. You can mimic delegate functionality by declaring and implementing an interface with a single method definition.
    The Java language doesn't have indexers either; you'd need to write them as regular class methods.
    Operator overloading
    The Java language doesn't allow operator overloading (a feature of C++ that made its way into C#). You easily can write methods to mimic the behavior of the overloaded operators.
    Unsafe mode
    C#'s unsafe mode lets you use pointers and pin blocks of memory in order to circumvent garbage collection. The Java runtime itself makes extensive use of pointers, but the Java language has no pointers and no equivalent of unsafe mode. This is in keeping with the Java platform's "Write Once, Run Anywhere" philosophy, which lets you safely avoid platform dependencies, memory leaks, and "runaway" code.Thank you in advance for any feedback.
    Regards,
    mathmax
    Edited by: mathmax on Sep 30, 2008 9:09 PM

    These points are still correct for [Java SE 6|http://java.sun.com/javase/6/].

  • My source does not compile in 1.5 because of generics in libraries

    Hi,
    I have a problem with my source codes written for 1.3 and 1.4 java. I have been implementing Iterator, Collection, List and extending ArrayList in many ocassions. All works as expected in 1.4 but if I try to compile it with 1.5 it does not compile. I do receive many errors which generally speaking are showing that compiler does think that X subclass is not the same as a subclass of X<?> generic which simply makes all my code to not compile.
    Does anybody had similar problems with their code? Does anybody knows how to rewrite problematic code so that it will compile under BOTH 1.4 and 1.5 without -source 1.4 option?
    Some examples, stripped to problematic parts:
    public class CSectionList extends ArrayList
    public final boolean add(Object element)
                 int p = Collections.binarySearch(this,element);
    /** Here comes error:
    cannot find symbol
    symbol  : method binarySearch(sztejkat.utils.CSectionList,java.lang.Object)
    location: class java.util.Collections
                    int p = Collections.binarySearch(this,element);
              if (p<0)
    public class CMemoryViewTable extends JTable
    /** Here comes error:
    name clash: setDefaultRenderer(java.lang.Class,javax.swing.table.TableCellRenderer) in sztejkat.hdl.debugger.ui.CMemoryViewTable and setDefaultRenderer(java.lang.Class<?>,javax.swing.table.TableCellRenderer) in javax.swing.JTable have the same erasure, yet neither overrides the other
    public class CMemoryViewTable extends JTable
        public void setDefaultRenderer(Class columnClass,
                                             TableCellRenderer renderer)
              if (renderer!=null)
                   super.setDefaultRenderer(columnClass,new CCursorRenderer(renderer));
              }else
               super.setDefaultRenderer(columnClass,null);
    }In first example it seems to not catch that my CSectionList is a List<>, while in second it does not treat Class and Class<> equally what makes compiler to think that I don't override setDefaultRenderer method what I actually wanted to do (and did in 1.4).
    Please help...
    regards,
    Tomasz Sztejka
    P.S.
    Where the source compatibility have gone between 1.4 and 1.5? If it will look like this I strongly vote to NOT touch java language specification - it was very nice, simple and clear language. With autoboxing and generics it starts to do a lot of things behind my back what I don't like - this is why I moved from C++ to Java - hate what C++ did with overloaded operators. But maybe I'm just to stupid.

    Hi,
    I'm still not getting a good grip on generics, and still think they are not necessary.True, but when you have assembler you might not need C or Java. With assembler, you can write the most efficient programmes, but fixing a bug is not easy. With the higher level of C and Java, fewer trivial errors are made. The introduction of generics is another step towards compile-time bug prevention.
    Will your request block me from having a set of different classes,
    derived from different superclasses, all
    implementing Comparable in the way, that they use
    instanceof to check for proper relation (ie. I would
    like to sorting to sort all classes A by some value
    and all classes B to land in front of list)?Regarding raw classes, my request will change the erased interface of Comparable from
    int compareTo(Object o);to
    int compareTo(Comparable o);This would mean that all non-generic implementions of Comparable would have to be modified. I should have requested this enhancement ten years ago, but back then I did not know about Java at all :(
    Where largest common superclass is Object (ie Asuper
    is not instanceof Bsuper and vice-versa).
    Will soring list of such objects (both A and B) will
    be legal after your RFE ?Both A and B implement Comparable, so that should not be a problem.

  • Conversion of long and int: strange result and no warning

    Why does Java allow this?
    long l = Long.MAX_VALUE / 10;
    System.out.println(l); // result 922337203685477580
    int i = (int)l;
    System.out.println(i); // result -858993460The compiler accepts it and the runtime accepts it. Why? Complete nonsense is the result!
    The same happens with using a Long object and calling the intValue() method.
    Can someone explain it to me?

    What do you think of operator overloading?Well, I don't have much influence -:) But this is what Guy Stele, SUN Fellow, say:
    Overloaded operators are still a subject of controversy. They are almost indispensable for certain kinds of mathematical work, but people who oppose adding them to the Java language point out, quite rightly, that the feature was badly abused in C++ for nonmathematical purposes, making code much harder to read than necessary. Most Java applications are nonmathematical in nature. One could make a good argument that commercial applications have no need for operator overloading, except that commercial applications do use (or should use) BigDecimal arithmetic, and it would be really nice to be able to use + and - and * and / with BigDecimal numbers. Much the same can be said of so-called "lightweight classes": their greatest value would lie in supporting numerical concepts such as complex numbers and interval arithmetic.
    We have an interesting decision to make that is more a political or business question than a technical one: should the Java language be extended to support the needs of mathematical applications? If so, then I would argue strongly for introducing operator overloading and lightweight classes -- I'm pretty sure such facilities would also get used for other purposes. If not, then maybe we should just make + and - and * and / work for the BigInteger and BigDecimal classes as a special case, much the same way that + is already a special case for the String class.

  • C or c++

    hi all,
    It's time for me to learn a new something new. I thinking of learning c or c++ but not sure which one to go with.
    Could anyone make some good sugestions? and possible reasons for using on over the other
    my history so far is as follows
    Qbasic
    Vbasic 6
    vb.net
    python
    PHP
    Kind Regards
    Matthew

    TheBodziO wrote:If you want to write a program and see objects—choose c++.
    Or Objective-C (a real superset of C), or just use loosely coupled functions operating on a single struct. All OOP principles can be emulated using C. Glibc, Objective-C, Python, Io, and a bunch of other languages/libraries are proof of this.
    jamesbannon wrote:C++ - you can write C programs using it
    Umm, no you can't. C++ and C are different languages and are incompatible with each other.
    jamesbannon wrote:it has all the OO "goodies" and generic programming.
    You mean templates? One could argue if that's a good thing
    As far as writing a backup utility, I wouldn't really use either languages, unless you require good performance. Use a higher-level language, like Python. If you want to learn a new language then look for some other high-level language. C is especially tedious to work with at times. In the long run it will be a smarter choice to use a higher-level language.
    If you wish to learn a new language then C would be a great start. It teaches you a lot about the processor, memory, and generally about programming. It's basically like the Linux of operating systems. If you want a language with OOP support, my favorites are Objective-C (learning C beforehand would be beneficial) and Python. Objective-C is a strict superset of C, meaning that you can compile a C program with an Objective-C compiler. It is strictly typed, but allows for dynamic typing (by using id, much like void * in C). It uses messages rather than calling functions, like Smalltalk. It has properties, so you don't have to write getters and setters. It has a nice system for memory management, and some implementations have garbage collection. It has a bunch of other cool features such as Categories. The biggest downside is popularity and compatibility - it's the main languages used for Mac OS (and iPhone) development, but isn't really used anywhere else. Python is nice because it is multi-paradigm and supports a bit of functional programming. It's duck typing allow for a lot of "magic" and reduces complexity. It has nice support for creating portable programs.
    If you want to learn something new then perhaps look into Lisp, Haskell, Erlang, or any of the other functional languages. Haskell is a very interesting one since it is a pure functional language and makes you think a lot more about designing functions. However, it does have quite a steep learning curve.
    I would advise against using C++. It might be beneficial to be familiar with it, but in my opinion it's a very ugly language. The most annoying thing is templates. Defining them seems like a hack - having to write the implementation in the "interface" (.h file). Using them isn't that great either. It's mostly just a hacky workaround for being statically compiled and calling functions, rather than sending messages. In Objective-C "templates" are trivial and very natural to implement. You basically specify a protocol, and just send the message. In Python this is achieved by being dynamically typed. I'm not really a fan of overloading operators either. Not so much the concept, but some implementations, which are less than intuitive. I'm sure there are more things that annoy me, but I haven't used C++ for a long time, and I'm not all that familiar with it either, so I'll just link to another rant about C++.
    TLDR:
    For the backup utility use a high-level language like Python.
    If you just want to learn a new language look into functional languages like Haskell.

  • Assigning objects

    i'm trying to assign an object to another of the same kind. but i cannot do so. i used to program in C++ and this was done by overloading operators. any idea how can i do this in java this is the code of what i'm trying to do
    FDfields temp = new FDfields(fileName, mode, fdcounter, nextblknum);
                   fdtable[counter]= temp;fdtable is an array of FDfields objects

    i was testing it and found out that my FDfields object never gets created this is my code for FDfields class and how i access is how i showed early can you tell me what i'm doing wrong apriciate your help
    package FileSystemPack;
    public class FDfields
    //this class contain the fields of the table which will keep track of the files
         String fileName;
         int ifopen;
         int fd;
         String mode;
         int blknum;
         Inode this_file;//= new Inode(fileName, mode);
         public FDfields(String fileName, String mode, int fd, int blknum)
              fileName= fileName;
              fd= fd;
              mode= mode;
              blknum= blknum;
              ifopen=1;
              this_file= new Inode(fileName, mode);
         public FDfields(FDfields obj)
              fileName= obj.fileName;
              fd= obj.fd;
              mode= obj.mode;
              blknum= obj.blknum;
              ifopen= obj.ifopen;
              this_file= obj.this_file;
         public String get_fileName()
              return fileName;
         public String get_mode()
              return mode;
         public int get_status()
              return ifopen;
         public int get_fd()
              return fd;
         public int get_blknum()
              return blknum;
         public Inode get_Inode()
              return this_file;
    }this is the function where i create the object
    public class FileSystem
         public static FDfields [] fdtable =new FDfields[10];
         Disk diskobj= new Disk();
         static int counter= 0;
         static int fdcounter=0;
         static int nextblknum=0;
         public int f_open(String fileName, String mode)
              //System.out.println("test0");
              for(int i=0; i<counter; i++)
                   int temp_fd=0;
                   //System.out.print("test");
                   try{
                   if(fdtable.get_fileName().equals(fileName))
                        //System.out.print("test1");
                        temp_fd=fdtable[i].get_fd();
                        fdtable[i].ifopen=1;
                        fdtable[i].mode=mode;
                        //counter++;
              return temp_fd;
              }catch (Exception e){
              System.out.print(e);}
              if(counter<10 && counter>=0)
                   int temp_blk=0;
                   byte[] buf = new byte[64];
                   counter++;
                   fdcounter++;
                   FDfields temp = new FDfields(fileName, mode, fdcounter, nextblknum);
                   fdtable[counter]= new FDfields(temp);
                   fdtable[counter].this_file.inodeToBuffer(buf);
                   //fdtable[counter].mode=mode;
                   //fdtable[counter].this_file(fileName, mode);
                   //fdtable[counter].fd=fdcounter++;
                   try
                        temp_blk=diskobj.put_block(nextblknum, buf);
                   }catch(DiskException ex){
                        System.out.println("Exception: " + ex);
                   fdtable[counter].this_file.set_address(temp_blk);
                   nextblknum=temp_blk;
                   System.out.println();
                   System.out.print(temp.get_fileName());
                   System.out.println();
                   System.out.print(fdtable[counter].get_fileName());
                   return fdcounter;
              else
                   System.out.print("The maximum number of open files have reached");
                   return -1;

  • Why not Integer.NaN?

    Hello
    I wonder why Integer does not supply a NaN like Double.NaN. I find the Double.Nan to be very useful.
    Regards
    JT

    :) I think what you mean is that integers are
    normally only used with the basic arithmetic
    operations: +, -, *, and / (I miss having Python's
    built-in exponentiation operator). These operations
    never return infinity or NaN, with the single notable
    exception of division by zero. And dividing by zero
    is almost always an accident with integers, and is
    easy to check for.Yes, that's what I meant. My post was so dumb even I have to laugh at it. First, I didn't say integers are closed over multiplication, and then I said modulo and remainder like they're two different things. And integers aren't closed under integer division because of 0, as you said.
    Floating point numbers, on the other hand, are often
    used with transcendental functions and fractional
    exponents and things, which frequently result in
    infinity or NaN. Moreover, it's important to be able
    determine that the result is one of those things, so
    we have constants for them. Also, it's often hard to
    check these things ahead of time with these
    functions.
    You dig?
    As an aside, I wonder if an operator-overloading
    framework could be developed for Java by explicitly
    basing the use of operators on interfaces. For
    instance, to use the arithmetic operators, you would
    implement an interface called Field. To use
    the comparison operators, you would implement an
    interface called Ordered (which would
    basically be identical to the Comparable interface).
    You get the idea. The premise would be that it
    t would the operators to conform with their standard
    mathematical definitions.As someone adamantly opposed to operator overloading in Java, this proposal is ok to me. If you're familiar with the matlab language, operator overloading is done there by defining functions like "plus()", etc... so its sort of similar I think. I think C++ gets difficult because you can overload operators like the function call operator (), and the member of operator(s) which gets confusing really quick.

  • Bitwise operators in XSLT:-

    Hi ,
    Does XSLT has support for BITWISE operations, If so Can you please help me out of that >
    If not , Is there any other way to apply BITWISE logic to the flow in the BPEL.
    I tried it using Java Embedded activity in the BPEL, but I am getting the following Exception SCAC-50012,tried referring to this Exception, but not able to get the exact view of that error., as this activity in the BPEL doesnt have JAVA editor I am not able to point out the same.

    Hi everybody,
    I have the following queries in JAVA.
    1)Is "Operator Overloading" is nothing but
    but "Method Overloading" in Java?There's no operator overloading in Java. For example + can't be changed to mean something else.
    2)Regarding BitWise Operators, i just wanna have
    have an simple example abt the usage of bitwise
    operators. i.e., in real world where we will be using
    these ?Just one example of many is the use of bitwise XOR in simple encryption/decryption. The scheme is called XOR scrambling.
    byte key = 0x77; // a key byte 0101 0101
    byte any = ......; // any byte to be scrambled
    byte scramble = key ^ any; // the scrambled byte
    byte unscramble = key ^ scramble; // unscramble == any, the original byte is back againIt builds on the fact that if you XOR any byte with a bit pattern (key) two times you get the original byte back again.

  • Vivado 2015.2: Simulation and synthesis reverse bit order of std_logic_vector in logical operators

    In both simulation and synthesis the logical operators on std_logic_vector bit-reverse the operands in the result, at least in the case where the result of the expression is passed to a function.
    I suspect this issue applies to other operators as well, though I have only tested the problem with the logical operators. I also suspect the issue exists in other situations where a function is not involved. 
    This is incompatible with both ModelSim simulation and XST synthesis and it breaks a lot of our code.
    The attached xsim7.vhd example shows the issue. The xsim7.tcl script will run the Vivado simulation. Under Windows, the xsim7.bat will run the whole thing. The xsim7.xpr project file allows synthesis under Vivado, and you can look at the schematic to see the issue in the synthesized netlist.
    The source module also simulates under ModelSim and synthesizes under XST, and these show what I believe to be correct behavior.
    Can someone please verify this error and either file a CR or tell me to file an SR?
    Ian Lewis
    www.mstarlabs.com

    Hello Bharath,
    When I said "what was index 'LOW becomes index 'HIGH" I meant the 'LOW of the source operands and the 'HIGH of the result, independent of the actual index range. I would have no problem with any 'HIGH and 'LOW on the result of the operator as long as the direction matched the left source operand, though personally I would prefer the same 'HIGH and 'LOW as that of the left operand.
    Looking at the IEEE implementation of logical "or" on std_logic_vector from package std_logic_1164: https://standards.ieee.org/downloads/1076/1076.2-1996/std_logic_1164-body.vhdl:
    -- or
    FUNCTION "or" ( l,r : std_logic_vector ) RETURN std_logic_vector IS
    ALIAS lv : std_logic_vector ( 1 TO l'LENGTH ) IS l;
    ALIAS rv : std_logic_vector ( 1 TO r'LENGTH ) IS r;
    VARIABLE result : std_logic_vector ( 1 TO l'LENGTH );
    BEGIN
    IF ( l'LENGTH /= r'LENGTH ) THEN
    ASSERT FALSE
    REPORT "arguments of overloaded 'or' operator are not of the same length"
    SEVERITY FAILURE;
    ELSE
    FOR i IN result'RANGE LOOP
    result(i) := or_table (lv(i), rv(i));
    END LOOP;
    END IF;
    RETURN result;
    END "or";
    the operator does exactly what Vivado seems to be doing: alias the downto source vectors to a to range of 1 to 'LENGTH and then return a vector of 1 to 'LENGTH. This both bit reverses the downto indexes (the alias on the source operands does that) and changes the range to "to" with a 'LOW value of 1.
    This gives us the 'LEFT 1 and 'RIGHT 4 we see.
    So far, I have found no definition from IEEE of what logical operators, such as "or", are supposed to do on std_logic_vector except as defined by this piece of code for "or" and the other operators' associated bodies from the std_logic_1164 package.
    What this code does seems like a horrible decision about how to implement the logical operators on std_logic_vector with respect to range direction, but it is compatible with what Vivado does, and incompatible with what XST does. (I had never investigated this issue before because what ModelSim and XST did made perfect sense to me.)
    That the assignment  (Result := s)  works as expected, makes sense. The assignment of the "to" range s to the "downto" range Result maintains the 'LEFT relationship. That is, Result'LEFT (index 3) receives s'LEFT (index 1). So, the bits are reversed a second time.
    That ISIM does not match what XST does seems like a defect no matter how you look at it. Your simulation can never match your synthesis if you care about the range direction inside a function (and I suspect in other places too). This deserves an SR or CR if you are still doing any work on those two tools. I think you may not be.
    Are you able to find out whether Vivado was changed from XST on purpose with respect to the behavior of logical operators?
    If this is "as designed" then I have to start working on updating our code to live with it. But, if this is something that happened by accident, and you will change Vivado to match XST, then I probably want to wait. Updating our code to live with this behavior is going to be a pretty big job.
    Thank you for your help,
    Ian

  • Built-in overloaded operator

    what is built-in overloading in java.
    explain me with example.

    what is built-in overloading in java.
    explain me with example.I may be responsible for that but it isn't an established term. Java has a number of operators working on primitive types, but Java doesn't have overloading so you can't redefine them and make them work on your own classes. There's an intermediate case though and that's the + opererator working on String, like
    String s = "this" + "that";This could be called "built-in" overloading I'd say. I think BigNumber is a strong candidate to given its own set of operators, maybe in version 1.6.

  • Error: Overloading ambiguity between "operator+(const RWCString&, const RWC

    We always get the following error when we are compiling our source codes:
    Error: Overloading ambiguity between "operator+(const RWCString&, const RWCString&)" and "RWCString::operator const char*() const"
    Our compiler is Workshop 6 update 1. We can compile the same source codes in Workshop 5.0. We found out that we can solve this problem if we explicitly cast the const strings to RWCString. However, since we are building on previous source codes and modules, we find this solution close to impossible. Is there other solution for this problem? Are there any patch which we can use?
    Thanks!

    The code really does have an ambiguity in it.
    The RWCString class operator() member function, which you invoke as str1(...) with an integer value, returns a char. You then have the operation
            RWCString + char
    The RWCString class does not have an associated operator+ that takes a RWCString and a character. The compiler could convert the string to a char* via "operator const char*" and add the value of the char to it, or it could convert the char to a RWCString via a constructor and use the operator+ that takes two RCWCstrings.
    The compiler has no way to prefer one choice over the other.
    You can write an explicit cast, or you can store the result of the str1(...) operation in an explicit RWCString temp, or you could use the += operator:
    str2 = str2 + RWCString(str1(str1.length()-1));
    RWCString temp = str1(str1.length()-1);
    str2 = str2 + temp;
    str2 += str1(str1.length()-1);
    BTW, this problem illustrates why it's usually a bad idea to have multiple constructors and also type conversion operators in a class. It's hard to write code that doesn't lead to ambiguities.

  • Why only +String concatation for Operator Overloading ?

    Java does not support operator overloading other than the + operator for addition of two Strings or a number and a String.Why only the + operator and Strings, even when we have a concat() for addition of Strings ?
    Wondering if anyone could provide me some link as to why this only this (+) operator was chosen.
    Thank you for your consideration.
    Edited by: amtidumpti on Apr 27, 2009 6:40 AM
    Edited by: amtidumpti on Apr 27, 2009 6:40 AM

    amtidumpti wrote:
    stevejluke wrote:
    amtidumpti wrote:
    Java does not support operator overloading other than the + operator for addition of two Strings or a number and a String.Why only the + operator and Strings, even when we have a concat() for addition of Strings ? I assume the + was implemented (even with the concat() method present) for simplicity with working with Strings. Why only +? What other operators make sense as String manipulation operators? Why are they useful?We already have String,StringBuilder,StringBuffer for simplicity and manipulations of Strings or may be they were added later,but even then we have this +.Right, and you can use those methods instead of +. But String is a much-used class, has several special attributes given to it, and the + is very self-explanatory when applied to Strings.
    Also would == qualify as the other operator for operator overloading in java ?== has no special meaning for Strings (or really for Objects at all). It has exactly one purpose, to compare the value of the operands provided. When the operands are primitives, it compares their values exactly as you or I would (if the primitive values are equal you get true). When the operands are reference types the value of the references are tested for equality (if they don't hold a reference to the same Object, then == returns false).
    >
    int iAge1=0,iAge2=0;
    String sName1="Java",sName2="Rocks";
    double dMark1=89.02,dMark2=92.0;
    if(iAge1==iAge2)
    System.out.println("HURRAH");
    if(sName1==sName2)
    System.out.println("HURRAH");
    if(dMark1==dMark2)
    System.out.println("HURRAH");Also in case of boolean :
    boolean bFlag1=false,bFlag2=true;
    if(bFlag1=bFlag2)
    System.out.println("Value Assignment done");Here is " = " working not only as a assignment operator as well as conditional operator ?
    Thanks for your consideration.

  • Set operators over ore.frame

    Is there a way to make set operators work with ore.objects without ore.pull?
    EXAMPLE:
    > df1 <- data.frame(ID=c(1:3),A=rep(1,3))
    > df2 <- data.frame(ID=c(2:4),B=rep(1,3))
    > class(df1)
    [1] "data.frame"
    > # Union
    > union(df1$ID,df2$ID)
    [1] 1 2 3 4
    > # Minus
    > setdiff(df1$ID,df2$ID)
    [1] 1
    > #Intersect
    > intersect(df1$ID,df2$ID)
    [1] 2 3
    > #-------------------------------------------------
    > of1 <- ore.push(df1)
    > of2 <- ore.push(df2)
    > class(of1)
    [1] "ore.frame"
    attr(,"package")
    [1] "OREbase"
    > # Union
    > union(of1$ID,of2$ID)
    integer(0)
    > # Minus
    > setdiff(of1$ID,of2$ID)
    integer(0)
    > #Intersect
    > intersect(of1$ID,of2$ID)
    integer(0)
    > #-------------------------------------------------
    > vec1 <- ore.push(df1$ID)
    > vec2 <- ore.push(df2$ID)
    > class(vec1)
    [1] "ore.integer"
    attr(,"package")
    [1] "OREbase"
    > union(vec1,vec2)
    integer(0)

    Many of the commonly used base R functions are overloaded in the Oracle R Enterprise transparency layer to work with ore.frame objects.  These functions are located in the OREbase and OREstats packages.
    For example, to get the union, use merge, as it has been overloaded to operate on ore.frame objects:
    R> find("merge")
    [1] "package:OREbase" "package:base"  
    merge(x = of1, y = df2, all = TRUE)
    R> merge(x = of1, y = of2, all = TRUE)
    ID  A  B
    1|NA  1  1 NA
    2|1   2  1  1
    3|2   3  1  1
    NA|3  4 NA  1
    to subtract:
    R> find("Arith")
    [1] "package:OREbase" "package:methods"
    of1$A - of2$B
    R> of1$A - of2$B
    [1] 0 0 0
    There is no need to pull the data if the function is overloaded to work with ore.frame objects.  More examples can be found in the ORE 1.4 Training Materials: Oracle R Enterprise 1.4 Transparency Layer: http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/learnmore/ore-1-4-transparency-layer-215…
    You can view the functions in the OREbase and OREstats packages by typing:
    ls("package:OREbase")
    ls("package:OREstats")
    Sherry

Maybe you are looking for