| 160 | |
| 161 | |
| 162 | class NestedInteger: |
| 163 | def __init__(self, ni): |
| 164 | nested = [] |
| 165 | if (isList(ni)): |
| 166 | for i, val in enumerate(ni): |
| 167 | nested.append(NestedInteger(val)) |
| 168 | self.nested = nested |
| 169 | self.ni = ni |
| 170 | |
| 171 | def isInteger(self) -> bool: |
| 172 | """ |
| 173 | @return True if this NestedInteger holds a single integer, rather than a nested list. |
| 174 | """ |
| 175 | if (isList(self.ni)): |
| 176 | return False |
| 177 | return True |
| 178 | |
| 179 | def getInteger(self) -> int: |
| 180 | """ |
| 181 | @return the single integer that this NestedInteger holds, if it holds a single integer |
| 182 | Return None if this NestedInteger holds a nested list |
| 183 | """ |
| 184 | if (isList(self.ni)): |
| 185 | return None |
| 186 | return self.ni |
| 187 | |
| 188 | def getList(self): |
| 189 | """ |
| 190 | @return the nested list that this NestedInteger holds, if it holds a nested list |
| 191 | Return None if this NestedInteger holds a single integer |
| 192 | """ |
| 193 | if (isList(self.ni)): |
| 194 | return self.nested |
| 195 | return None |
| 196 | |
| 197 | |
| 198 | def parseNestedIntegerArray(param): |
no outgoing calls
no test coverage detected