如何在向量数组中插入元素?

时间:2018-10-20 07:40:10

标签: c++ arrays vector

如何在其中插入元素?

vector <int> arr[10];

然后在需要时如何在向量中的位置arr [i]处插入更多元素?

1 个答案:

答案 0 :(得分:0)

public class MyClass {

    private final ReadOnlyBarProperty bar = new ReadOnlyBarProperty();

    public final Bar getBar() {
        return barProperty().get();
    }

    private void setBar(Bar bar) {
        this.bar.set(bar);
    }

    public ReadOnlyObjectProperty<Bar> barProperty() {
        return bar;
    }

    [...]

    private class ReadOnlyBarProperty extends ReadOnlyObjectPropertyBase<Bar> {

        private Bar bar = null;

        @Override
        public final Bar get() {
            return bar;
        }

        private void set(Bar newValue) {
            if (!Objects.equals(bar, newValue)) {
                bar = newValue;
                fireValueChangedEvent();
            }
        }

        @Override
        public Object getBean() {
            return MyClass.this;
        }

        @Override
        public String getName() {
            return "bar";
        }
    }
}