protected override ShaveState UpdateState(T key, ShaveState state, StateUpdate update)
        {
            var weight = 0.0;

            for (int i = 0; i < update.inputs1.Count; i++)
            {
                weight += update.inputs1[i].weight;
            }
        protected override ShaveState UpdateState(T key, ShaveState state, int update)
        {
            Int64 weight = 0;

            //Console.WriteLine("update: {0}", update);

            var index = update;

            while (index >= 0)
            {
                //all diffs we have received
                weight += updateChain[index].update.weight;
                index   = updateChain[index].previous;
            }

            //Console.WriteLine("weight: {0}", weight);
#endif

            //var weight = update.update.weight;
            //for (int i = 0; update.additionalUpdates != null && i < update.additionalUpdates.Count; i++)
            //    weight += update.additionalUpdates[i].weight;

            // Console.WriteLine("Weight: " + weight);

            while (weight > 0)
            {
                var delta = Math.Min(weight, GetIncrement(state.index, key) - state.value);
                //state.index = index and reminder
                Send(new Weighted <R>(reducer(state.index, key), delta));

                weight      -= delta;
                state.value += delta;

                if (weight > 0.0)
                {
                    state.index += 1;
                    state.value  = 0;
                }
            }

            while (weight < 0)
            {
                var delta = Math.Max(weight, 0 - state.value);

                Send(new Weighted <R>(reducer(state.index, key), delta));

                weight      -= delta;
                state.value += delta;

                if (weight < 0)
                {
                    state.index -= 1;
                    state.value  = GetIncrement(state.index, key);
                }
            }

            return(state);
        }