When you set int vectorSize = (int)xVal.size(); it will get the current size of the vector.
After you inserted some elements, you should update the value of vectorSize or it would still be 0.
You might be better off keeping your X and Y coordiates together in some kind of record. If you wanted to add a z coordinate, or if you wanted to change the type to longlong, it would make it easier.