Managing bit flags in an array of bytes

In my program, I have a large array of bytes. Some arbitrarily long groups of bytes in this array act as groups of bit flags. I need to be able to retrieve and manipulate these bit flags. I read that the best way to do this is with bitwise operations; something I have never learned before. I wrote methods that seem to work, but because I have never done anything like this before, can someone check my work?
Here is an example program, where the only contents of the byte array is a single two-byte grouping of 16 bit flags:
public class test
    static byte[] bytes = new byte[2];
    static byte[] pow2 = {1, 2, 4, 8, 16, 32, 64, -128};
    static byte[] pow2i = {-2, -3, -5, -9, -17, -33, -65, 127};
    public static void main(String[] args) throws Exception
        writeBitFlag(0, 6, true);
        for (int i = 0; i < 16; i++)   
            System.out.println("Flag " + i + ": " + getBitFlag(0, i));
        System.out.println();
        writeBitFlag(0, 12, true);
        invertBitFlag(0, 0);
        invertBitFlag(0, 0); 
        invertBitFlag(0, 1);
        for (int i = 0; i < 16; i++)   
            System.out.println("Flag " + i + ": " + getBitFlag(0, i));  
    }//end main
    public static boolean getBitFlag(int startAddress, int flag)
        return (bytes[startAddress + flag / 8] & pow2[flag %= 8]) == pow2[flag];
    }//end getBitFlag
    public static void invertBitFlag(int startAddress, int flag)
        bytes[startAddress + flag / 8] ^= pow2[flag % 8];
    }//end invertBitFlag
    public static void writeBitFlag(int startAddress, int flag, boolean flagVal)
        if (flagVal)
            bytes[startAddress + flag / 8] |= pow2[flag % 8];
        else
            bytes[startAddress + flag / 8] &= pow2i[flag % 8];
    }//end writeBitFlag      
}//end class testDoes this look like the right way to do what I am trying to do?

You could try BitSet which provides these function for you.
public class test { 
    public static void main(String[] args) throws Exception {   
        byte[] bytes = new byte[2];
        writeBitFlag(bytes, 6, true);
        for (int i = 0; i < bytes.length*8; i++)   
            System.out.println("Flag " + i + ": " + getBitFlag(bytes, i));
        System.out.println();
        writeBitFlag(bytes, 12, true);
        invertBitFlag(bytes, 0);
        invertBitFlag(bytes, 0); 
        invertBitFlag(bytes, 1);
        for (int i = 0; i < bytes.length*8; i++)   
            System.out.println("Flag " + i + ": " + getBitFlag(bytes, i));  
    }//end main
    public static boolean getBitFlag(byte[] bytes, int flag) {
        return ((bytes[flag >> 3] >> flag) & 1) != 0;
    public static void invertBitFlag(byte[] bytes, int flag) {
        bytes[flag >> 3] ^= (1 << (flag & 7));
    public static void writeBitFlag(byte[] bytes, int flag, boolean flagVal) {
        if (flagVal)
            bytes[flag >> 3] |= (1 << (flag & 7));
        else
            bytes[flag >> 3] &= ~(1 << (flag & 7));
}//end class test

Similar Messages

  • How to chnage number of bits in every packet of a byte array

    Hi I have an array of byte array of 1 and 0s. I would like to make sure every pack of 1 or 0s contains 8 number
    I can use this example to explain it better. Lets say I have this array
    111111110000000111111100000000
    As can be first pack of 0s and the second pack of 1s contain 7 bits. I would like to programaticaaly change it to 8 so the result should be
    11111111000000001111111100000000 
    As can be seen now evey pack of 1s or 0s contains 8 element . Could you please help me on this.A sample code would be great
    Many thanks

    Reshape array is your friend.Nevermind.  I just realized what you were going for.  Will need to rethink...
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    8x bits long.png ‏21 KB

  • How to convert an array of bits into an array of bytes?

    If I have an array of 1s and 0s, how can I pack them
    into an array of bytes (8 bits)?
    Thanks.

    NI recommends to get rid of 4.x mode (Quote from the help file: "National Instruments recommends reworking any application that uses the Convert 4.x Data mode as a long term solution."). For this reason, I have attached an alternative example to give you some ideas.
    (The previous example (using 4.x type cast) is actually slightly flawed, because for some reason it only produces even sized output arrays (why???) so you would need to trim the resulting array as a function of the input array size.)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    OnesAndZeroesU8v2.vi ‏43 KB

  • Bit Flags VS Boolean Flags

    Hi here are two code snippets:
    One with boolean flags;
    public class BooleanFlags {
         private boolean _flag1 = false;
         private boolean _flag2 = false;
         private boolean _flag3 = false;
         private boolean _flag4 = false;
         public boolean isFlag1() {
              return this._flag1;
         public void setFlag1(boolean flag1) {
              this._flag1 = flag1;
         public boolean isFlag2() {
              return this._flag2;
         public void setFlag2(boolean flag2) {
              this._flag2 = flag2;
         public boolean isFlag3() {
              return this._flag3;
         public void setFlag3(boolean flag3) {
              this._flag3 = flag3;
         public boolean isFlag4() {
              return this._flag4;
         public void setFlag4(boolean flag4) {
              this._flag4 = flag4;
    }Another with bit flags
    public class BitFlags {
         static final int _FLAG1 = 1;
         static final int _FLAG2 = 2;
         static final int _FLAG3 = 4;
         static final int _FLAG4 = 8;
         private int _flags = 0;
         public int getFlags() {
              return this._flags;
         public void setFlags(int flags) {
              this._flags = flags;
    }Testing code
    public class TestFlags {
         public static void main(String[] args) {
              // bit
              BitFlags t = new BitFlags();
              t.setFlags(t.getFlags() | BitFlags._FLAG1);
              t.setFlags(t.getFlags() | BitFlags._FLAG2);
              if ((t.getFlags() & BitFlags._FLAG2) == BitFlags._FLAG2) {
                   System.out.println("FLAG2");
              //boolean
              BooleanFlags bf = new BooleanFlags();
              bf.setFlag1(true);
              bf.setFlag2(true);
              if ( bf.isFlag2() ) {
                   System.out.println("FLAG2");
    }I counted the number bytes used by each classes.
    Each character of a class name weighs 3 bytes each.
    For a default package BitFlags.class file weighs
    for 1 flag 519 bytes
    for 2 flags 549 bytes
    for 3 flags 579 bytes
    for 4 flags 609 bytes
    So that's 30 bytes per flags.
    BooleanFlags.class file weighs
    for 1 flag 484 bytes
    for 2 flag 686 bytes
    for 3 flags 888 bytes
    for 4 flags 1090 bytes
    So that's 202 bytes per flags.
    I don't know though how the size of the class file is correlated with the memory used at run time. Apparently boolean flags suck.
    But wait.
    A) Which one is the most efficient memory wise at run time?
    Degrees of freedom:
    -the number of flags used,
    -the number of instances that will be created.
    An important question needs to be answered, that is whether a boolean literal weighs indeed a 1 bit of memory or more. I don't know.
    When reasoning from a conceptual point of view, the memory usage for bit flags will take 4 bytes per instance for the _flags field and a constant 4 bytes per static flag definition,
    N > 0, X > 0
    32 * N + X*32 = A bits
    Boolean flags take 1 bit per instance per flag
    1 * N * X = B bits
    So if we want A > B
    32N >(N-32) X
    If N > 32 then 32N/(N-32) > X
    If N = 32 then INF>X
    If N < 32 then 32N/(N-32) < X
    To have A > B we need
    N = 1 : 0 < X < INF
    N = 31 : 0 < X < INF
    N = 32 : 0< X < INF
    N = 33 : 0 < X < 1056
    N = 40 : 0 < X < 160
    N = 50 : 0 < X < 89
    N = 100 : 0 < X < 48
    N = 10000 : 0 < X < 33
    As you can guess, as N goes to infinite, X goes to 32.
    For a very large number of instances, boolean flags will take less memory than bit flags if you have less than 32 flags (dual will take more memory if have more than 32 flags) Boolean flags always beat bit flags for less than 33 instances
    Now I don't know what really happens in practice. Because one should take heed of the way classes are managed. The code for getting boolean flags takes a lot of room. Now if that code is loaded once. That's ok. But if the get and set methods for every bit flags are loaded for every instance. Then that's bad.
    A solution to this would be to use public members and remove getters and setters.
    The most important issue though is how boolean literal are managed by the memory.
    From a purely aesthetic perspective, the usage of boolean flag is nicer. Testing the value of a bit flag is ugly.
    Cheers

    The hardware level is irrelevent. If the best you can
    do is "look for multiple boolean variables in the same
    class and pack them into a single byte," why can't
    this be done by JVM writers for you?
    Although tecnically possible, I suspect only that someone who didn't know what they were doing would implement it that way.
    First keep in mind that this is something the VM must do. The compiler has nothing to do with. And it does mean that just for the VM to access values (not via java) that the code will be slower. It is because of this that C/C++ language allows developers to decide whether to pack integer numerics or not.
    Second consider the following...
        void myMethod()
           boolean b = true;
              boolean b1_1 = true;
              String s1 = "test";
              boolean b1_2 = true;
              String s2 = "test";
              boolean b2_1 = true;
              boolean b2_1 = true;
        }Now the compiler is going to render the above by using stack frame references as
    #1 = b
    #2 = b1_1 and s2
    #3 = s1 and b2_1
    #4 = b1_2 and b2_1
    So now the VM is going to have to know that #1 holds all the bits and sometimes those bits are used by #2 and sometime not.
    Now one could write code that would do that. But I would be a lot slower and I suspect it would actually take more space due to maintenance information information needed to handle it all.
    And the result would be that all Java apps would be slower and only a few (definitely less than 1%) would save any space. I don't think a reasonable VM vendor would take that path.

  • How to Convert array of int into array of byte - please help

    I have a 2-dim array of type int and I want to convert it to an array
    of byte. How can I do that? Also, if my 2-dim int array is one dimention
    can I use typecast as in the example below?
    private byte[] getData()
    byte []buff;
    int []data = new int[5];
    //populate data[]
    buff = (byte[]) data; <---- CAN I DO THIS??????
    return buff;

    hi, I suggest you make an array of byte arrays
    --> Byte[][] and use one row for each number
    you can do 2 things,
    take each cipher of one number and put one by one in each column of the row correspondent to that number. of course it may take too much room if the int[] is too big, but that is the easiest way I think
    the other way is dividing your number into bitsets(class BitSet) with sizes of 8 bits and then you can save each bit into each column of your array. and you still have one number in each row. To put your numbers back use the same class.
    Maybe someone has an easier way, I couldnt think of any.

  • How can I convert an array off byte into an Object ?

    Hi folks...
    I�m developing an application that comunicates a PDA and a computer via Wi-Fi. I�m using a DataStream ( Input and Output ) to receive / send information from / to the computer. Most off the data received from him is in the byte[] type...
    How can I convert an array off byte ( byte[] ) into an Object using MIDP 2.0 / CLDC 1.1 ?
    I found on the web 2 functions that made this... but it uses a ObjectOutputStream and ObjectInputStream classes that is not provided by the J2ME plataform...
    How can I do this ?
    Waiting answers
    Rodrigo Kerkhoff

    There are no ObjectOutputStream and ObjectInputStream classes in CLDC. You must know what you are writing to and reading from the DataStream. You should write the primitives like int, String to the DataOutputstream at one end and read those in exactly the same sequence at the outher end using readInt(), readUTF() methods.

  • Array of bytes..

    hi..
    how can i convert array of bytes to string and vise versa
    thanks

    You can convert the string to a char array with String.toCharArray(), but if you want them as a byte array you have to first decide what character encoding should be used with the conversion. You can e.g. use "8859_1" if you only work with characters in the range 0 to 255. Then it would be String.getBytes("8859_1"). You have to add a try-catch block. It will throw an exception if you use an unsupported encoding. ISO 8859-1 is one of the basic supported encodings, so you will not get any exceptions when you use this.
    To go the other way, you use one of the String constructors.

  • Array of bytes containg punctuatio​n

    Hi, I have an array of bytes that I would like to export using the spreadsheet VI. The spreadsheet creates a file with the extension .res, which logs the array as hex values. The problem is, all my data is separated with a punctuation mark, which I guess LabView inserts into the array to separate the numbers.
    So my question is, is there any way to convert an array of U8's into a string of pure hex or just a stream of binary data?
    Thanks

    q-bertsuit wrote:
    Thank you for your answers, I'll try your link. The first suggested solution didn't work.
    You are not giving enough information. Did the second suggestion work?
    q-bertsuit wrote:
    I want to use the spreadsheet VI to make a .res file, saving as a plain text file would cause alot of extra work in MatLab.
    A "spreadsheet" in LabVIEW is nothing more than a plain text file with certain delimiters for columns and newlines delimiting rows. "Write to spreadsheeet file" is a simple tool for typical use. All the formatting can be done explicit and then written to a plain text file, the outcome is exactly the same. There is no extra work involved in Matlab.
    q-bertsuit wrote:
    I might not have explained the problem sufficiently in the first post. If my buffer containing U8s is passed in to the spreadsheet VI, the .res file saves for example the number 255 as ASCII character 2 then character 5 then 5. So 255 would be saved as 32 35 35 instead of FE.
    Again, write to spreadsheet file is not the right tool then, so don't use it.
    It is still not clear. So you have an array of U8. How should the file look like? Should there be any delimiters?
    Example: If you only write 255 to the file, should it contain
    one binary, nonpritable character (xFF)
    two charcters (two instances of the letter F)
    Three characters (letter 2 followed by two letters 5)
    If the array has two elements, how should the second character be stored? Should there be a delimiter (space, comma, tab, etc) or nothing separating it from the first value?
    Once we have the specifications, the rest will be trivial.
    LabVIEW Champion . Do more with less code and in less time .

  • Read array of bytes

    using what do i read array of bytes that is on a stream...
    i send an array of bytes to the invoking stream using void write(byte buffer[])....
    how do i read it from the other side....
    uzair

    Attempts to read up to buffer.length bytes into
    buffer, returning the number of bytes that were
    sucessfully read. -1 is returned when the end of the
    file is encountered.I wasn't asking you to post what the API says it does. We know what it does. Now, do you understand how it reads the bytes into the buffer that you pass to it?

  • How to send array of bytes to a servlet and store it in a file

    Hi,
    How to send array of bytes to a servlet and store it in a file.
    I am new to Servlets. if possible for any one, please provide the code.
    Thanks,
    cmbl

    Through HTTP this is only possible with a POST request of which the encoding type is set to multipart/form-data. You can use Apache Commons FileUpload to parse such a multipart form data request into useable elements. From the other side (the client) you can use a HTML <input type="file"> element or a Java class with Apache Commons PostMethod API.
    You may find this article useful: http://balusc.blogspot.com/2007/11/multipartfilter.html

  • Definition of Asset Reorganization,eg Manage History flag in class define?

    Hello.
    The F1 help behind the "Manage Historically" flag in Asset Class definition states one of the effects is:"The asset and the values/transactions belonging to it cannot be reorganized until the asset is deactivated."
    What does "reorganized" refer to in this context?
    I've searched this forum, and there are references using the term but not including any reference to the definition. Googling variations on SAP/Asset/reorg has returned some great results, e.g. a 500+ page amazingly complete detail manual from SAP on fixed assets that I'm very happy to have found, but even that does not define the term in tht context of Fixed assets. Searching for the term in the document points to a page that simply states"For more information on archiving and reorganization of asset data, see Archiving in the R/3 System [Ext.]." So I've got it narrowed down to having something to do with archiving.
    So here's my specific question; At the highest possilble level,e.g. one or two sentences, can someone tell me what the term "Reorganization" refers to in this context?
    Any info would be appreciated.
    Thanks.

    Hello David,
    Whenever you're confronted with an issue of this sort, the first thing you have do to is to break the down the issue or definition.  Your main bone of contention is the word "Reorganization".
    In this instance, if I were you, I will take the this issue out of the realm of technicality or SAP and try to understand what the word "reorganize" means.
    "Reorganize" means to effect changes or organize something new.  Although "historically or history" means a written record or systematic record of events or accounts, SAP is saying, if you check "manage historically" in the asset master record, in order for you to reorganize the asset record, you would have to deactivate the check.
    Let's take a typical example:  Your company implemented IRFS standard IAS16 and therefore you need to make some changes to your property, plant and equipment which may also require changes to your depreciation expense, asset values as a result of new useful life etc.  You can't do any of this if you check manage history.  It does not however means you cannot post depreciation values.  What you cannot do though is make changes.
    If you ask in the asset accounting category forum the number of companies which have activated this check, I'm pretty sure you might not even get one.  We have fixed asset module activated at my company and we've never had this check activated.  And I did the whole config. from A to Z.
    Finally, it is good to play around the issue in your sandbox client and that will give you a better idea of the function.
    Regards,
    Elias

  • Converting an array of bytes to an image

    I think this is the right forum for my question.
    This code comes from the J2ME side of my application. It reads in an int from my server, and if its over a certain length, I can tell its an image so i can decode it from an array of bytes back into an image, but it throws an IllegalArgument Exception on image = Image.createImage(b,0,length);
    I've decoded the byte array before it gets sent and convereted it back into an image and that works, and ive run the debugger and the array is full of numbers on the J2ME side of the app, but the call to createImage, just keeps throwing this exception and i can't find an answer. If you need anymore code, I'll post it.
    int l = in.readInt();
    imageArray = new ImageItem[l];
    for(int i = 0; i < imageArray.length; i++){
    byte[] b = null;
    int length = in.readInt();
    System.out.println("length = " + length);
    if(length < 10) {
    imageArray[i] = null;
    System.out.println("null image");
    } else {
    b = new byte[length];
    in.readFully(b,0,length);
    System.out.println("image not null");
    Image image = Image.createImage(b,0,length);
    System.out.println("hit");
    ImageItem imageItem = new ImageItem("null", image, 0, "null");
    imageArray[i] = imageItem;
    If anyone can tell me how to indent the code, i would appreciate it, it looks indented when i post it my side.
    Message was edited by:
    trisonetwo
    Message was edited by:
    trisonetwo

    If it works before sending then check your code for sending the image.
    Also you can compare the byte array before sending with the array which was received at the other end.
    For indent and syntex highliting use [ c o d e ] and [ / c o d e ] tags (without spaces)
    Ex:-
    int l = in.readInt();
    imageArray = new ImageItem[l];
    for(int i = 0; i < imageArray.length; i++){
       byte[] b = null;
       int length = in.readInt();
       System.out.println("length = " + length);
       if(length < 10) {
          imageArray = null;
          System.out.println("null image");
       } else {
          b = new byte[length];
          in.readFully(b,0,length);
          System.out.println("image not null");
          Image image = Image.createImage(b,0,length);
          System.out.println("hit");
          ImageItem imageItem = new ImageItem("null", image, 0, "null");
         imageArray = imageItem;
    }

  • Reading an array of byte with special delimiter....help me!!

    Hi guys,
    i've developed a java application that has in input a txt file with a standard format
    string string string
    string double double
    string double double
    and stores it into an array of byte with a fixed format,
    that is byte(whitespace)byte(whitespace)byte(;)byte(whitespace)byte(whitespace)byte(;)byte(whitespace)byte(whitespace)byte(;)
    that mean introducing byte whitespace value and byte ; value to separate different columns and different rows.
    Now i have to develop inverse routine,that has to read the array of byte and rebuild its original format.
    Can you help me with some idea ord code?
    I'm inexepert...please help me with clear suggest...
    I post you my routine that converts txt file into an array of byte
    P.S.In my txt file number of columns and rows change for each file,what is standard is a firtst headline that is an array of string and others row with the same format string array of doubles....
    public byte[] getBytes(){
              byte middlerow=' ';
              byte endrow=';';
              Vector temp=new Vector(10000000);
              int i=0;     
              String g=null;
              Riga r;
              Double val[];
              while(i<intest.length){
                   //copio tutto nell'array di byte
                   byte []bytes = intest.getBytes();
    //               memorizza in byte un elemento del vettore alla volta
                   for( Byte aByte : bytes ) {
                   temp.addElement( aByte );
                   temp.addElement( Byte.valueOf( middlerow ) );
                   i++;
              temp.addElement(Byte.valueOf(endrow));
              System.out.println("Intestazione convertita in byte");
              for(int l=0;l<rows.size()-1;l++){
                   r=(Riga)rows.get(l);
                   g=r.getgeneid();
              temp.addElement(g.getBytes());
              temp.addElement(Byte.valueOf(middlerow));
              val=r.getvalues();
              for(int e=0;e<=val.length-1;e++){
              temp.addElement(Byte.valueOf(val[e].byteValue()));
              //val[e].byteValue() fa il casting double in byte
              temp.addElement(Byte.valueOf(middlerow));
         temp.addElement(Byte.valueOf(endrow));
              byte [] b=new byte[temp.size()];
              for (int k=0;i<temp.size();i++){
                   b[k]=(((Byte)temp.elementAt(k)).byteValue());
              return b;
    Thanks for your help...

    Ahh, how is the "array of bytes" being populated, Java code?
    If so which encoding are you using? When you create the bytes (from a string at a guess) the other end which encoding do you use?
    If you are using a db, why not use a db? Why this blob of data?
    If I really was banned from using the DB as a DB, and HAD (on pain of death) to use this wonky blob thing, I would do:
    Writing:
    ByteArrayOutputStream daos = new ByteArrayOutputStream() ;
    DataOutputStream dos = new DataOutputStream( daos );
    dos.writeUTF( "me String" );
    dos.writeDouble( 4.2 );
    dos.close;
    byte[] stickInUglyBlob = daos.toByteArray() ;
    Reading:
    DataInputStream dis = new DataInputStream( new ByteInputStream( blobOfUckyness ) );
    String meString = dis.readUTF();
    double meDouble = dis.readDouble();

  • Converting a PNG image to an array of bytes and vice versa..

    hi all,
    i need to convert a PNG image to an array of bytes ,then converting back this array of bytes to The PNG image again ,i read this can be done using output streams but i feel like a dump and i can't fix the whole thingy out ! ,can anybody help me in this ,by explaining how can this be established????
    Regards,
    D.Roth

    hi all,
    i need to convert a PNG image to an array of bytes ,then converting back this array of bytes to The PNG image again ,i read this can be done using output streams but i feel like a dump and i can't fix the whole thingy out ! ,can anybody help me in this ,by explaining how can this be established????
    Regards,
    D.Roth

  • Getting file into an array of byte..

    Hi guys,
    i first thank you for all the help you've given in my precedent posts.
    Now i've to ask you a question.
    I need to convert some lines of a txt file(obtained from an excel table) into an array of byte in the best possible manner.
    My file can have a various number of rows and columns.
    With this code
    BufferedReader br = new BufferedReader(new InputStreamReader(myFile.getInputStream()));
    String line = null;
            while ((line = br.readLine()) != null) {
                    line = line.replace (',', '.');
                    StringTokenizer st = new StringTokenizer(line);
                    numberOfNumericColumns = (st.countTokens()-1);
                    col=(numberOfNumericColumns+1);I read the file, i change , with . and line to line i calculate the number of value(that have to be the same,i do the control for showing exception if necessary).
    Now i know from my file what are the number of values in a row(columns of my old excel table).
    I have to convert this file into an array of byte.
    How can i do it?
    Suppose we have only 3 lines, the first line is ever only string,the others lines have a string and other double values.....
    nome giuseppe carmine paolo
    valerio 23.3 34.3 43.3
    paolo 21.2 34.5 12.2
    each value is separated from another one by one or more whitespaces..
    The most important thing is that in a second moment i have to read this array of byte and showing its original content,so i have to put in the array some different value and different line symbol delimiter.
    Can you help me giving me some idea or code?(please be clear,i'm inexpert of java...)
    Thanks very much,i need your help
    Message was edited by:
    giubat

    thanks for your reply...
    my file has about 50000 rows..........and i have to develop an application that allows the upload of about 6000/7000 files....
    so i have to optimize everythings......i want to use whitespace to separate different value and ;different line
    so in my array of bytes i want
    nome(converted in byte) whitespace(in byte) giuseppe (in byte) whitespace(in byte)carmine(in byte) whitespace(in byte) paolo (in byte) ;(in byte);
    valerio(in byte) whitespace(in byte) 23.3 (in byte) whitespace(in byte) 34.3 (in byte) whitespace(in byte)43.3 (in byte) ;(in byte) etc.....So i should have an array of byte lower than the array of byte obtained converting each line as a string into bytes.......
    do you understand what's my problem?
    How can i create an array of byte without fixing its initial dimension that is able to grows up for each line read?
    Excuse for my poor english..
    In the past i've used a vector to temporary store the data while reading the file and at the end i copied the vector in the array of byte but when i do upload in my application i had java heap size error.
    So someone has suggested me to improve my storing method and i've decided to eliminate vector....
    can you help me......????
    please....i need your help..

Maybe you are looking for