public void adaptSegments(LinkedList<segmentUpdate> segmentList, Boolean positiveReinforcement) {
        for(segmentUpdate segUpd: segmentList) {
            // System.out.print(segUpd.segmentIndex[2] + "\r\n");
            if (segUpd.segmentIndex[2] < 0) {
                Segment newSegment = new Segment();
                for(Synapse syn: segUpd.activeSynapses) {
                    newSegment.synapses.add(syn);
                }
                newSegment.sequenceSegment = segUpd.sequenceSegment;
                dendriteSegments.get(segUpd.segmentIndex[0]).get(segUpd.segmentIndex[1]).add(newSegment);
            } else {
                Segment seg =  dendriteSegments.get(segUpd.segmentIndex[0]).get(segUpd.segmentIndex[1])
                        .get(segUpd.segmentIndex[2]);
                seg.sequenceSegment = segUpd.sequenceSegment;
                for(Synapse syn: seg.synapses) {
                    if (segUpd.activeSynapses.contains(syn)) {
                        if (positiveReinforcement)
                            syn.permanence += permanenceInc;
                        else
                            syn.permanence -= permanenceDec;
                    } else {
                        if (positiveReinforcement)
                            syn.permanence -= permanenceDec;
                        else
                            syn.permanence += permanenceInc;
                    }
                }
                for(Synapse syn: segUpd.activeSynapses) {
                    if (!seg.synapses.contains(syn)) {
                        seg.synapses.add(syn);
                    }
                }
            }
        }
    }