class OrderedStream {
public:
OrderedStream(int n) {
}
vector<string> insert(int idKey, string value) {
}
};
/**
* Your OrderedStream object will be instantiated and called as such:
* OrderedStream* obj = new OrderedStream(n);
* vector<string> param_1 = obj->insert(idKey,value);
*/
type OrderedStream struct {
mp map[int]string
ptr int
}
func Constructor(n int) OrderedStream {
return OrderedStream{
mp: make(map[int]string, n),
ptr:1,
}
}
func (this *OrderedStream) Insert(idKey int, value string) []string {
ans := []string{}
this.mp[idKey] = value
s, ok := this.mp[this.ptr]
for ok {
ans = append(ans, s)
this.ptr++
s, ok = this.mp[this.ptr]
}
return ans
}
/**
* Your OrderedStream object will be instantiated and called as such:
* obj := Constructor(n);
* param_1 := obj.Insert(idKey,value);
*/